1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s 3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 4 5 class A {}; // expected-note 4 {{previous use is here}} 6 enum E {}; 7 8 void a1(struct A); 9 void a2(class A); 10 void a3(union A); // expected-error {{use of 'A' with tag type that does not match previous declaration}} 11 void a4(enum A); // expected-error {{use of 'A' with tag type that does not match previous declaration}} 12 13 class A1 { 14 friend struct A; 15 friend class A; 16 friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} 17 18 friend enum A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} 19 friend enum E; 20 #if __cplusplus <= 199711L // C++03 or earlier modes 21 // expected-warning@-2 {{befriending enumeration type 'enum E' is a C++11 extension}} 22 #endif 23 }; 24 25 template <class T> struct B { // expected-note {{previous use is here}} 26 class Member {}; // expected-note 2 {{previous use is here}} 27 }; 28 29 template <> class B<int> { 30 // no type Member 31 }; 32 33 template <> struct B<A> { 34 union Member { // expected-note 4 {{previous use is here}} 35 void* a; 36 }; 37 }; 38 39 void b1(struct B<float>); 40 void b2(class B<float>); 41 void b3(union B<float>); // expected-error {{use of 'B<float>' with tag type that does not match previous declaration}} 42 //void b4(enum B<float>); // this just doesn't parse; you can't template an enum directly 43 44 void c1(struct B<float>::Member); 45 void c2(class B<float>::Member); 46 void c3(union B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} 47 void c4(enum B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} 48 49 void d1(struct B<int>::Member); // expected-error {{no struct named 'Member' in 'B<int>'}} 50 void d2(class B<int>::Member); // expected-error {{no class named 'Member' in 'B<int>'}} 51 void d3(union B<int>::Member); // expected-error {{no union named 'Member' in 'B<int>'}} 52 void d4(enum B<int>::Member); // expected-error {{no enum named 'Member' in 'B<int>'}} 53 54 void e1(struct B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} 55 void e2(class B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} 56 void e3(union B<A>::Member); 57 void e4(enum B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} 58 59 template <class T> struct C { 60 void foo(class B<T>::Member); // expected-error{{no class named 'Member' in 'B<int>'}} \ 61 // expected-error{{use of 'Member' with tag type that does not match previous declaration}} 62 }; 63 64 C<float> f1; 65 C<int> f2; // expected-note {{in instantiation of template class}} 66 C<A> f3; // expected-note {{in instantiation of template class}} 67