summaryrefslogtreecommitdiff
path: root/clang/test/CXX/class/class.mem/p13.cpp
blob: 84885848870e070840080f308e298712d5d2d61d (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// RUN: %clang_cc1 -fsyntax-only -verify %s

// If T is the name of a class, then each of the following shall have
// a name different from T:

// - every static data member of class T;
struct X0 {
  static int X0; // expected-error{{member 'X0' has the same name as its class}}
};

// - every member function of class T
// (Cannot be tested)

// - every member of class T that is itself a type;
struct X1 { // expected-note{{previous use is here}}
  enum X1 { }; // expected-error{{use of 'X1' with tag type that does not match previous declaration}}
};

struct X2 {
  typedef int X2; // expected-error{{member 'X2' has the same name as its class}}
};

// - every enumerator of every member of class T that is an enumerated type; and
struct X3 {
  enum E {
    X3 // expected-error{{member 'X3' has the same name as its class}}
  };
};

// - every member of every anonymous union that is a member of class T.
struct X4 {
  union {
    int X;
    union {
      float Y;
      unsigned X4; // expected-error{{member 'X4' has the same name as its class}}
    };
  };
};