diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-08-30 14:32:14 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-08-30 14:32:14 +0000 |
| commit | 2c7d9290eedeb4937026e01afac875cb79567f46 (patch) | |
| tree | 434d0cba1b996a8ce12a4c73da76ea64b7e8c61c /clang/test/CXX/class/class.mem/p1.cpp | |
| parent | 5209a0d850b24ed23671b5a02f538458fed08412 (diff) | |
| download | bcm5719-llvm-2c7d9290eedeb4937026e01afac875cb79567f46.tar.gz bcm5719-llvm-2c7d9290eedeb4937026e01afac875cb79567f46.zip | |
Add redeclaration checking for static data members and fix a corner
case with redeclaration checking for fields, from Faisal Vali!
Fixes PR7970.
llvm-svn: 112476
Diffstat (limited to 'clang/test/CXX/class/class.mem/p1.cpp')
| -rw-r--r-- | clang/test/CXX/class/class.mem/p1.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/clang/test/CXX/class/class.mem/p1.cpp b/clang/test/CXX/class/class.mem/p1.cpp new file mode 100644 index 00000000000..55507d4e961 --- /dev/null +++ b/clang/test/CXX/class/class.mem/p1.cpp @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct S +{ + static int v1; // expected-note{{previous declaration is here}} + int v1; //expected-error{{duplicate member 'v1'}} + int v; //expected-note 2{{previous definition is here}} \ + // expected-note{{previous declaration is here}} + static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} + int v; //expected-error{{duplicate member 'v'}} + static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} + enum EnumT { E = 10 }; + friend struct M; + struct X; //expected-note{{forward declaration of 'S::X'}} + friend struct X; +}; + +S::EnumT Evar = S::E; // ok +S::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}} +S::M m; //expected-error{{no type named 'M' in 'S'}} +S::X x; //expected-error{{variable has incomplete type 'S::X'}} + + +struct S2 +{ + static int v2; // expected-note{{previous declaration is here}} + static int v2; //expected-error{{duplicate member 'v2'}} +}; + +struct S3 +{ + static int v3; + struct S4 + { + static int v3; + }; +}; + +struct S4 +{ + static int v4; +}; + +int S4::v4; //expected-note{{previous definition is here}} +int S4::v4; //expected-error{{redefinition of 'v4'}} + +struct S5 +{ + static int v5; //expected-note{{previous definition is here}} + void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}} + + void v6() { } //expected-note{{previous definition is here}} + static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}} + + void v7() { } + void v7(int) { } //expected-note{{previous definition is here}} + static int v7; //expected-error{{redefinition of 'v7' as different kind of symbol}} + + void v8(); + int v8(int); //expected-note{{previous declaration is here}} + int v8; //expected-error{{duplicate member 'v8'}} + + +}; |

