Home | History | Annotate | Download | only in dcl.type.elab
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 class A {}; // expected-note 3 {{previous use is here}}
      4 
      5 void a1(struct A);
      6 void a2(class A);
      7 void a3(union A); // expected-error {{use of 'A' with tag type that does not match previous declaration}}
      8 void a4(enum A); // expected-error {{use of 'A' with tag type that does not match previous declaration}}
      9 
     10 class A1 {
     11   friend struct A;
     12   friend class A;
     13   friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}}
     14 
     15   friend enum A; // expected-error {{ISO C++ forbids forward references to 'enum' types}} \
     16                  // expected-warning {{cannot be a friend}}
     17 };
     18 
     19 template <class T> struct B { // expected-note {{previous use is here}}
     20   class Member {}; // expected-note 2 {{previous use is here}}
     21 };
     22 
     23 template <> class B<int> {
     24   // no type Member
     25 };
     26 
     27 template <> struct B<A> {
     28   union Member { // expected-note 4 {{previous use is here}}
     29     void* a;
     30   };
     31 };
     32 
     33 void b1(struct B<float>);
     34 void b2(class B<float>);
     35 void b3(union B<float>); // expected-error {{use of 'B<float>' with tag type that does not match previous declaration}}
     36 //void b4(enum B<float>); // this just doesn't parse; you can't template an enum directly
     37 
     38 void c1(struct B<float>::Member);
     39 void c2(class B<float>::Member);
     40 void c3(union B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
     41 void c4(enum B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
     42 
     43 void d1(struct B<int>::Member); // expected-error {{no struct named 'Member' in 'B<int>'}}
     44 void d2(class B<int>::Member); // expected-error {{no class named 'Member' in 'B<int>'}}
     45 void d3(union B<int>::Member); // expected-error {{no union named 'Member' in 'B<int>'}}
     46 void d4(enum B<int>::Member); // expected-error {{no enum named 'Member' in 'B<int>'}}
     47 
     48 void e1(struct B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
     49 void e2(class B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
     50 void e3(union B<A>::Member);
     51 void e4(enum B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
     52 
     53 template <class T> struct C {
     54   void foo(class B<T>::Member); // expected-error{{no class named 'Member' in 'B<int>'}} \
     55                                 // expected-error{{use of 'Member' with tag type that does not match previous declaration}}
     56 };
     57 
     58 C<float> f1;
     59 C<int> f2; // expected-note {{in instantiation of template class}}
     60 C<A> f3; // expected-note {{in instantiation of template class}}
     61