summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-01-06 21:54:29 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-01-06 21:54:29 +0000
commit0f56118c57387fe478742953519514cc350c5ea1 (patch)
treeeebda77f7f12a62acd1a66da2f636cd2ffa05f95 /clang/test
parent4954354666beded9acdc2e582286cd0c7e2f2b69 (diff)
downloadbcm5719-llvm-0f56118c57387fe478742953519514cc350c5ea1.tar.gz
bcm5719-llvm-0f56118c57387fe478742953519514cc350c5ea1.zip
Fix half of PR26048. We don't yet diagnose the case where the anonymous union member is declared first and the tag name is declared second.
llvm-svn: 256979
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/class/class.mem/p13.cpp4
-rw-r--r--clang/test/CXX/class/class.union/class.union.anon/p1.cpp26
-rw-r--r--clang/test/CXX/class/class.union/class.union.anon/p4.cpp (renamed from clang/test/CXX/class/class.union/p8.cpp)0
-rw-r--r--clang/test/SemaCXX/anonymous-union.cpp4
4 files changed, 30 insertions, 4 deletions
diff --git a/clang/test/CXX/class/class.mem/p13.cpp b/clang/test/CXX/class/class.mem/p13.cpp
index 1d7b9bc8155..bc01fd4d30c 100644
--- a/clang/test/CXX/class/class.mem/p13.cpp
+++ b/clang/test/CXX/class/class.mem/p13.cpp
@@ -58,12 +58,12 @@ struct X3a {
};
// - every member of every anonymous union that is a member of class T.
-struct X4 {
+struct X4 { // expected-note{{previous}}
union {
int X;
union {
float Y;
- unsigned X4; // expected-error{{member 'X4' has the same name as its class}}
+ unsigned X4; // expected-error{{redeclares 'X4'}}
};
};
};
diff --git a/clang/test/CXX/class/class.union/class.union.anon/p1.cpp b/clang/test/CXX/class/class.union/class.union.anon/p1.cpp
new file mode 100644
index 00000000000..7fef4c5d172
--- /dev/null
+++ b/clang/test/CXX/class/class.union/class.union.anon/p1.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -verify %s
+
+struct X {
+ int a; // expected-note {{previous}}
+ void b(); // expected-note {{previous}}
+ struct c; // expected-note {{previous}}
+ typedef int d; // expected-note {{previous}}
+
+ union {
+ int a; // expected-error {{member of anonymous union redeclares}}
+ int b; // expected-error {{member of anonymous union redeclares}}
+ int c; // expected-error {{member of anonymous union redeclares}}
+ int d; // expected-error {{member of anonymous union redeclares}}
+ int e; // expected-note {{previous}}
+ int f; // expected-note {{previous}}
+ int g;
+ int h; // expected-note {{previous}}
+ };
+
+ int e; // expected-error {{duplicate member}}
+ void f(); // expected-error {{redefinition}}
+ // FIXME: This is ill-formed, even though one name is a tag and the other is
+ // an anonymous union member. Reject this.
+ struct g;
+ typedef int h; // expected-error {{redefinition}}
+};
diff --git a/clang/test/CXX/class/class.union/p8.cpp b/clang/test/CXX/class/class.union/class.union.anon/p4.cpp
index cc54ba40661..cc54ba40661 100644
--- a/clang/test/CXX/class/class.union/p8.cpp
+++ b/clang/test/CXX/class/class.union/class.union.anon/p4.cpp
diff --git a/clang/test/SemaCXX/anonymous-union.cpp b/clang/test/SemaCXX/anonymous-union.cpp
index 3520245a03a..0b654266f75 100644
--- a/clang/test/SemaCXX/anonymous-union.cpp
+++ b/clang/test/SemaCXX/anonymous-union.cpp
@@ -62,11 +62,11 @@ void test_unqual_references(X x, const X xc) {
struct Redecl {
int x; // expected-note{{previous declaration is here}}
- class y { };
+ class y { }; // expected-note{{previous declaration is here}}
union {
int x; // expected-error{{member of anonymous union redeclares 'x'}}
- float y;
+ float y; // expected-error{{member of anonymous union redeclares 'y'}}
double z; // expected-note{{previous declaration is here}}
double zz; // expected-note{{previous definition is here}}
};
OpenPOWER on IntegriCloud