diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Parser/cxx-class.cpp | 2 | ||||
-rw-r--r-- | test/Sema/anonymous-struct-union.c | 82 | ||||
-rw-r--r-- | test/SemaCXX/anonymous-union.cpp | 3 | ||||
-rw-r--r-- | test/SemaObjC/property-9.m | 4 |
4 files changed, 88 insertions, 3 deletions
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 39b787fc8d..7ad63446ab 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -8,7 +8,7 @@ protected: struct S {}; enum {}; - int; // expected-error {{error: declaration does not declare anything}} + int; // expected-error {{declaration does not declare anything}} int : 1, : 2; public: diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c new file mode 100644 index 0000000000..72790c9abb --- /dev/null +++ b/test/Sema/anonymous-struct-union.c @@ -0,0 +1,82 @@ +// RUN: clang -fsyntax-only -verify %s +struct X { + union { + float f3; + double d2; + } named; + + union { + int i; + float f; + + union { + float f2; + double d; + }; + }; + + struct { + int a; + float b; + }; +}; + +void test_unqual_references(struct X x, const struct X xc) { + x.i = 0; + x.f = 0.0; + x.f2 = x.f; + x.d = x.f; + x.f3 = 0; // expected-error{{no member named 'f3'}} + x.a = 0; + + xc.d = 0.0; // expected-error{{read-only variable is not assignable}} + xc.f = 0; // expected-error{{read-only variable is not assignable}} + xc.a = 0; // expected-error{{read-only variable is not assignable}} +} + + +struct Redecl { + int x; // expected-note{{previous declaration is here}} + struct y { }; + + union { + int x; // expected-error{{member of anonymous union redeclares 'x'}} + float y; + double z; // expected-note{{previous declaration is here}} + double zz; // expected-note{{previous declaration is here}} + }; + + int z; // expected-error{{duplicate member 'z'}} + void zz(); // expected-error{{duplicate member 'zz'}} \ + // expected-error{{field 'zz' declared as a function}} +}; + +union { // expected-error{{anonymous unions must be struct or union members}} + int int_val; + float float_val; +}; + +static union { // expected-error{{anonymous unions must be struct or union members}} + int int_val2; + float float_val2; +}; + +void f() { + int_val2 = 0; // expected-error{{use of undeclared identifier}} + float_val2 = 0.0; // expected-error{{use of undeclared identifier}} +} + +void g() { + union { // expected-error{{anonymous unions must be struct or union members}} + int i; + float f2; + }; + i = 0; // expected-error{{use of undeclared identifier}} + f2 = 0.0; // expected-error{{use of undeclared identifier}} +} + +// <rdar://problem/6483159> +struct s0 { union { int f0; }; }; + +// <rdar://problem/6481130> +typedef struct { }; // expected-error{{declaration does not declare anything}} diff --git a/test/SemaCXX/anonymous-union.cpp b/test/SemaCXX/anonymous-union.cpp index 872c45c468..5860ed4af7 100644 --- a/test/SemaCXX/anonymous-union.cpp +++ b/test/SemaCXX/anonymous-union.cpp @@ -108,3 +108,6 @@ struct BadMembers { protected: float x2; // expected-error{{anonymous union cannot contain a protected data member}} }; }; + +// <rdar://problem/6481130> +typedef union { }; // expected-error{{declaration does not declare anything}} diff --git a/test/SemaObjC/property-9.m b/test/SemaObjC/property-9.m index 9275b51d25..9aafcc9ef6 100644 --- a/test/SemaObjC/property-9.m +++ b/test/SemaObjC/property-9.m @@ -43,9 +43,9 @@ typedef signed char BOOL; int _awesome; } -@property (readonly) int; // expected-warning {{declaration does not declare anything}} +@property (readonly) int; // expected-error {{declaration does not declare anything}} @property (readonly) ; // expected-error {{type name requires a specifier or qualifier}} \ - expected-warning {{declaration does not declare anything}} + expected-error {{declaration does not declare anything}} @property (readonly) int : 4; // expected-error {{property requires fields to be named}} |