Ignore const/volatile/restrict qualifiers on anonymous structs and
unions. Fixes PR8326.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131109 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/anonymous-union.cpp b/test/SemaCXX/anonymous-union.cpp
index 553ae65..2dd7ab8 100644
--- a/test/SemaCXX/anonymous-union.cpp
+++ b/test/SemaCXX/anonymous-union.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
struct X {
union {
float f3;
@@ -17,7 +17,7 @@
void test_unqual_references();
- struct {
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
int a;
float b;
};
@@ -125,7 +125,7 @@
// <rdar://problem/7987650>
namespace test4 {
class A {
- struct {
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
int s0; // expected-note {{declared private here}}
double s1; // expected-note {{declared private here}}
union {
@@ -136,7 +136,7 @@
union {
int u0; // expected-note {{declared private here}}
double u1; // expected-note {{declared private here}}
- struct {
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
int us0; // expected-note {{declared private here}}
double us1; // expected-note {{declared private here}}
};
@@ -175,3 +175,25 @@
};
}
}
+
+namespace PR8326 {
+ template <class T>
+ class Foo {
+ public:
+ Foo()
+ : x(0)
+ , y(1){
+ }
+
+ private:
+ const union { // expected-warning{{anonymous union cannot be 'const'}}
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
+ T x;
+ T y;
+ };
+ T v[2];
+ };
+ };
+
+ Foo<int> baz;
+}