1// RUN: %clang_cc1 -verify -pedantic %s
2
3template<typename T> struct atomic {
4  _Atomic(T) value;
5
6  void f() _Atomic; // expected-error {{expected ';' at end of declaration list}}
7};
8
9template<typename T> struct user {
10  struct inner { char n[sizeof(T)]; };
11  atomic<inner> i;
12};
13
14user<int> u;
15
16// Test overloading behavior of atomics.
17struct A { };
18
19int &ovl1(_Atomic(int));
20int &ovl1(_Atomic int); // ok, redeclaration
21long &ovl1(_Atomic(long));
22float &ovl1(_Atomic(float));
23double &ovl1(_Atomic(A const *const *));
24double &ovl1(A const *const *_Atomic);
25short &ovl1(_Atomic(A **));
26
27void test_overloading(int i, float f, _Atomic(int) ai, _Atomic(float) af,
28                      long l, _Atomic(long) al, A const *const *acc,
29                      A const ** ac, A **a) {
30  int& ir1 = ovl1(i);
31  int& ir2 = ovl1(ai);
32  long& lr1 = ovl1(l);
33  long& lr2 = ovl1(al);
34  float &fr1 = ovl1(f);
35  float &fr2 = ovl1(af);
36  double &dr1 = ovl1(acc);
37  double &dr2 = ovl1(ac);
38  short &sr1 = ovl1(a);
39}
40
41typedef int (A::*fp)() _Atomic; // expected-error {{expected ';' after top level declarator}} expected-warning {{does not declare anything}}
42
43typedef _Atomic(int(A::*)) atomic_mem_ptr_to_int;
44typedef int(A::*_Atomic atomic_mem_ptr_to_int);
45
46typedef _Atomic(int)(A::*mem_ptr_to_atomic_int);
47typedef _Atomic int(A::*mem_ptr_to_atomic_int);
48
49typedef _Atomic(int)&atomic_int_ref;
50typedef _Atomic int &atomic_int_ref;
51typedef _Atomic atomic_int_ref atomic_int_ref; // ok, qualifiers on references ignored in this case.
52
53typedef int &_Atomic atomic_reference_to_int; // expected-error {{'_Atomic' qualifier may not be applied to a reference}}
54typedef _Atomic(int &) atomic_reference_to_int; // expected-error {{_Atomic cannot be applied to reference type 'int &'}}
55
56struct S {
57  _Atomic union { int n; }; // expected-warning {{anonymous union cannot be '_Atomic'}}
58};
59