summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/class
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-07-06 01:45:27 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-07-06 01:45:27 +0000
commit88fe69ce210ecbec9f4850aed2c56074ef310437 (patch)
treee4856ac18a5b883c9b935d133bda1ec4286d9b95 /clang/test/CXX/class
parenta60a6db73f36f72ed7ad1474b713630d938c42eb (diff)
downloadbcm5719-llvm-88fe69ce210ecbec9f4850aed2c56074ef310437.tar.gz
bcm5719-llvm-88fe69ce210ecbec9f4850aed2c56074ef310437.zip
DR1909: Diagnose all invalid cases of a class member sharing its name with the class.
llvm-svn: 241425
Diffstat (limited to 'clang/test/CXX/class')
-rw-r--r--clang/test/CXX/class/class.mem/p13.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/clang/test/CXX/class/class.mem/p13.cpp b/clang/test/CXX/class/class.mem/p13.cpp
index 84885848870..1d7b9bc8155 100644
--- a/clang/test/CXX/class/class.mem/p13.cpp
+++ b/clang/test/CXX/class/class.mem/p13.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
// If T is the name of a class, then each of the following shall have
// a name different from T:
@@ -9,23 +9,53 @@ struct X0 {
};
// - every member function of class T
-// (Cannot be tested)
+struct Xa {
+ int Xa() {} // expected-error{{constructor cannot have a return type}}
+};
// - 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 X1 {
+ enum X1 { }; // expected-error{{member 'X1' has the same name as its class}}
+};
+
+struct X1a {
+ struct X1a; // expected-error{{member 'X1a' has the same name as its class}}
};
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 X2a {
+ using X2a = int; // expected-error{{member 'X2a' has the same name as its class}}
+};
+
+// - every member template of class T
+
+struct X2b {
+ template<typename T> struct X2b; // expected-error{{member 'X2b' has the same name as its class}}
+};
+struct X2c {
+ template<typename T> void X2c(); // expected-error{{constructor cannot have a return type}}
+};
+struct X2d {
+ template<typename T> static int X2d; // expected-error{{member 'X2d' has the same name as its class}}
+};
+struct X2e {
+ template<typename T> using X2e = int; // expected-error{{member 'X2e' has the same name as its class}}
+};
+
+// - every enumerator of every member of class T that is an unscoped enumerated type; and
struct X3 {
enum E {
X3 // expected-error{{member 'X3' has the same name as its class}}
};
};
+struct X3a {
+ enum class E {
+ X3a // ok
+ };
+};
// - every member of every anonymous union that is a member of class T.
struct X4 {
@@ -37,4 +67,3 @@ struct X4 {
};
};
};
-
OpenPOWER on IntegriCloud