xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/class/class.mem/p13.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // If T is the name of a class, then each of the following shall have
4*f4a2713aSLionel Sambuc // a name different from T:
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc // - every static data member of class T;
7*f4a2713aSLionel Sambuc struct X0 {
8*f4a2713aSLionel Sambuc   static int X0; // expected-error{{member 'X0' has the same name as its class}}
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc // - every member function of class T
12*f4a2713aSLionel Sambuc // (Cannot be tested)
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc // - every member of class T that is itself a type;
15*f4a2713aSLionel Sambuc struct X1 { // expected-note{{previous use is here}}
16*f4a2713aSLionel Sambuc   enum X1 { }; // expected-error{{use of 'X1' with tag type that does not match previous declaration}}
17*f4a2713aSLionel Sambuc };
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc struct X2 {
20*f4a2713aSLionel Sambuc   typedef int X2; // expected-error{{member 'X2' has the same name as its class}}
21*f4a2713aSLionel Sambuc };
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc // - every enumerator of every member of class T that is an enumerated type; and
24*f4a2713aSLionel Sambuc struct X3 {
25*f4a2713aSLionel Sambuc   enum E {
26*f4a2713aSLionel Sambuc     X3 // expected-error{{member 'X3' has the same name as its class}}
27*f4a2713aSLionel Sambuc   };
28*f4a2713aSLionel Sambuc };
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc // - every member of every anonymous union that is a member of class T.
31*f4a2713aSLionel Sambuc struct X4 {
32*f4a2713aSLionel Sambuc   union {
33*f4a2713aSLionel Sambuc     int X;
34*f4a2713aSLionel Sambuc     union {
35*f4a2713aSLionel Sambuc       float Y;
36*f4a2713aSLionel Sambuc       unsigned X4; // expected-error{{member 'X4' has the same name as its class}}
37*f4a2713aSLionel Sambuc     };
38*f4a2713aSLionel Sambuc   };
39*f4a2713aSLionel Sambuc };
40*f4a2713aSLionel Sambuc 
41