Richard Smith 715ee079da Related to PR37768: improve diagnostics for class name shadowing.
Diagnose the name of the class being shadowed by using declarations, and
improve the diagnostics for the case where the name of the class is
shadowed by a non-static data member in a class with constructors.  In
the latter case, we now always give the "member with the same name as
its class" diagnostic regardless of the relative order of the member and
the constructor, rather than giving an inscrutible diagnostic if the
constructor appears second.

llvm-svn: 335182
2018-06-20 21:58:20 +00:00

20 lines
426 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
// In addition, if class T has a user-declared constructor (12.1),
// every non-static data member of class T shall have a name different
// from T.
struct X0 {
int X0; // okay
};
struct X1 {
int X1; // expected-error{{member 'X1' has the same name as its class}}
X1();
};
struct X2 {
X2();
float X2; // expected-error{{member 'X2' has the same name as its class}}
};