diff options
| author | Serge Pavlov <sepavloff@gmail.com> | 2013-06-08 13:29:58 +0000 |
|---|---|---|
| committer | Serge Pavlov <sepavloff@gmail.com> | 2013-06-08 13:29:58 +0000 |
| commit | 89578fd4398130e24bf44e805f8f9688f72be7e1 (patch) | |
| tree | 7869f1c400cd3d1f1d8a2c6a442cf5b602ea1c2b /clang/test | |
| parent | ea7bb570580d1a82c8654d0ee3ce6b0a4419a35b (diff) | |
| download | bcm5719-llvm-89578fd4398130e24bf44e805f8f9688f72be7e1.tar.gz bcm5719-llvm-89578fd4398130e24bf44e805f8f9688f72be7e1.zip | |
Recognition of empty structures and unions is moved to semantic stage
Differential Revision: http://llvm-reviews.chandlerc.com/D586
llvm-svn: 183609
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Parser/declarators.c | 3 | ||||
| -rw-r--r-- | clang/test/Sema/array-init.c | 3 | ||||
| -rw-r--r-- | clang/test/Sema/empty1.c | 25 | ||||
| -rw-r--r-- | clang/test/Sema/empty2.c | 43 |
4 files changed, 72 insertions, 2 deletions
diff --git a/clang/test/Parser/declarators.c b/clang/test/Parser/declarators.c index f63b59f7caa..210a8e2befc 100644 --- a/clang/test/Parser/declarators.c +++ b/clang/test/Parser/declarators.c @@ -108,7 +108,8 @@ void test18() { } enum E1 { e1 }: // expected-error {{expected ';'}} -struct EnumBitfield { +struct EnumBitfield { // expected-warning {{struct without named members is a GNU extension}} enum E2 { e2 } : 4; // ok struct S { int n; }: // expected-error {{expected ';'}} + }; diff --git a/clang/test/Sema/array-init.c b/clang/test/Sema/array-init.c index f92852f341b..ae2c7425662 100644 --- a/clang/test/Sema/array-init.c +++ b/clang/test/Sema/array-init.c @@ -226,7 +226,8 @@ void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct is a GN // expected-error{{initializer for aggregate with no elements}} void noNamedInit() { - struct {int:5;} x[] = {6}; //expected-error{{initializer for aggregate with no elements}} + struct {int:5;} x[] = {6}; //expected-error{{initializer for aggregate with no elements}} \ +// expected-warning {{struct without named members is a GNU extension}} } struct {int a; int:5;} noNamedImplicit[] = {1,2,3}; int noNamedImplicitCheck[sizeof(noNamedImplicit) == 3 * sizeof(*noNamedImplicit) ? 1 : -1]; diff --git a/clang/test/Sema/empty1.c b/clang/test/Sema/empty1.c new file mode 100644 index 00000000000..cd4aca8e473 --- /dev/null +++ b/clang/test/Sema/empty1.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -Wc++-compat + +struct emp_1 { // expected-warning {{empty struct has size 0 in C, size 1 in C++}} +}; + +union emp_2 { // expected-warning {{empty union has size 0 in C, size 1 in C++}} +}; + +struct emp_3 { // expected-warning {{struct with only bit-fields of width 0 has size 0 in C, size 1 in C++}} + int : 0; +}; + +union emp_4 { // expected-warning {{union with only bit-fields of width 0 has size 0 in C, size 1 in C++}} + int : 0; +}; + +struct emp_5 { // expected-warning {{struct with only bit-fields of width 0 has size 0 in C, size 1 in C++}} + int : 0; + int : 0; +}; + +union emp_6 { // expected-warning {{union with only bit-fields of width 0 has size 0 in C, size 1 in C++}} + int : 0; + int : 0; +}; diff --git a/clang/test/Sema/empty2.c b/clang/test/Sema/empty2.c new file mode 100644 index 00000000000..68da5a8ee8a --- /dev/null +++ b/clang/test/Sema/empty2.c @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic + +struct emp_1 { // expected-warning {{empty struct is a GNU extension}} +}; + +union emp_2 { // expected-warning {{empty union is a GNU extension}} +}; + +struct emp_3 { // expected-warning {{struct without named members is a GNU extension}} + int : 0; +}; + +union emp_4 { // expected-warning {{union without named members is a GNU extension}} + int : 0; +}; + +struct emp_5 { // expected-warning {{struct without named members is a GNU extension}} + int : 0; + int : 0; +}; + +union emp_6 { // expected-warning {{union without named members is a GNU extension}} + int : 0; + int : 0; +}; + +struct nonamed_1 { // expected-warning {{struct without named members is a GNU extension}} + int : 4; +}; + +union nonamed_2 { // expected-warning {{union without named members is a GNU extension}} + int : 4; +}; + +struct nonamed_3 { // expected-warning {{struct without named members is a GNU extension}} + int : 4; + unsigned int : 4; +}; + +union nonamed_4 { // expected-warning {{union without named members is a GNU extension}} + int : 4; + unsigned int : 4; +}; |

