summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-08-11 07:29:54 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-08-11 07:29:54 +0000
commit8f0ed914902f2d108ca2bd0b64b32c876bf24e5c (patch)
treeddd509dc55c077e6d546b74efd9aa59b59d38fa1 /clang/test/Sema
parent69f3528c6abc83efd48977ba9c67150b93f15580 (diff)
downloadbcm5719-llvm-8f0ed914902f2d108ca2bd0b64b32c876bf24e5c.tar.gz
bcm5719-llvm-8f0ed914902f2d108ca2bd0b64b32c876bf24e5c.zip
Sema: Handle declspecs without declarators in records properly in C mode
We had two bugs: - We wouldn't properly warn when a struct/union/enum was mentioned inside of a record definition if no declarator was provided. We should have mentioned that this declaration declares nothing. - We didn't properly support Microsoft's extension where certain declspecs without declarators would act as anonymous structs/unions. * We completely ignored the case where such a declspec could be a union. * We didn't properly handle the case where a record was defined inside another record: struct X { int a; struct Y { int b; }; }; llvm-svn: 215347
Diffstat (limited to 'clang/test/Sema')
-rw-r--r--clang/test/Sema/MicrosoftExtensions.c15
-rw-r--r--clang/test/Sema/anonymous-struct-union.c2
2 files changed, 16 insertions, 1 deletions
diff --git a/clang/test/Sema/MicrosoftExtensions.c b/clang/test/Sema/MicrosoftExtensions.c
index 429dd943a74..f64012098b2 100644
--- a/clang/test/Sema/MicrosoftExtensions.c
+++ b/clang/test/Sema/MicrosoftExtensions.c
@@ -39,9 +39,24 @@ struct nested2 {
NESTED1; // expected-warning {{anonymous structs are a Microsoft extension}}
};
+struct nested3 {
+ long d;
+ struct nested4 { // expected-warning {{anonymous structs are a Microsoft extension}}
+ long e;
+ };
+ union nested5 { // expected-warning {{anonymous unions are a Microsoft extension}}
+ long f;
+ };
+};
+
+typedef union nested6 {
+ long f;
+} NESTED6;
+
struct test {
int c;
struct nested2; // expected-warning {{anonymous structs are a Microsoft extension}}
+ NESTED6; // expected-warning {{anonymous unions are a Microsoft extension}}
};
void foo()
diff --git a/clang/test/Sema/anonymous-struct-union.c b/clang/test/Sema/anonymous-struct-union.c
index 35d31754162..26dbeb87f5f 100644
--- a/clang/test/Sema/anonymous-struct-union.c
+++ b/clang/test/Sema/anonymous-struct-union.c
@@ -37,7 +37,7 @@ void test_unqual_references(struct X x, const struct X xc) {
struct Redecl {
int x; // expected-note{{previous declaration is here}}
- struct y { };
+ struct y { }; // expected-warning{{declaration does not declare anything}}
union {
int x; // expected-error{{member of anonymous union redeclares 'x'}}
OpenPOWER on IntegriCloud