diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-01-28 17:15:10 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-01-28 17:15:10 +0000 |
commit | fb034663885239079329e40d57eb59e32e08fa1a (patch) | |
tree | acfc9de664a1a6ec9925303094fcd1230fab42b0 /clang/test/SemaCXX | |
parent | aec0f37d11069598111997455602144b293f417d (diff) | |
download | bcm5719-llvm-fb034663885239079329e40d57eb59e32e08fa1a.tar.gz bcm5719-llvm-fb034663885239079329e40d57eb59e32e08fa1a.zip |
Complete semantic checking for typedef redeclarations in C++. The
rules are slightly different than in C, and now we handle both
dialects properly.
llvm-svn: 63211
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r-- | clang/test/SemaCXX/class.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/typedef-redecl.cpp | 25 |
2 files changed, 24 insertions, 3 deletions
diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp index d739af87dd7..02608faa0f6 100644 --- a/clang/test/SemaCXX/class.cpp +++ b/clang/test/SemaCXX/class.cpp @@ -30,7 +30,7 @@ public: func btm : 1; // expected-error {{error: bit-field 'btm' with non-integral type}} NestedC bc : 1; // expected-error {{error: bit-field 'bc' with non-integral type}} - enum E { en1, en2 }; + enum E1 { en1, en2 }; int i = 0; // expected-error {{error: 'i' can only be initialized if it is a static const integral data member}} static int si = 0; // expected-error {{error: 'si' can only be initialized if it is a static const integral data member}} diff --git a/clang/test/SemaCXX/typedef-redecl.cpp b/clang/test/SemaCXX/typedef-redecl.cpp index eabcef8b319..016882feb2b 100644 --- a/clang/test/SemaCXX/typedef-redecl.cpp +++ b/clang/test/SemaCXX/typedef-redecl.cpp @@ -1,12 +1,33 @@ // RUN: clang -fsyntax-only -verify %s - typedef int INT; typedef INT REALLY_INT; // expected-note {{previous definition is here}} typedef REALLY_INT REALLY_REALLY_INT; typedef REALLY_INT BOB; typedef float REALLY_INT; // expected-error{{typedef redefinition with different types ('float' vs 'INT')}} -class X { +struct X { typedef int result_type; // expected-note {{previous definition is here}} typedef INT result_type; // expected-error {{redefinition of 'result_type'}} }; + +struct Y; // expected-note{{previous definition is here}} +typedef int Y; // expected-error{{typedef redefinition with different types ('int' vs 'struct Y')}} + +typedef int Y2; // expected-note{{previous definition is here}} +struct Y2; // expected-error{{definition of type 'struct Y2' conflicts with typedef of the same name}} + +void f(); // expected-note{{previous definition is here}} +typedef int f; // expected-error{{redefinition of 'f' as different kind of symbol}} + +typedef int f2; // expected-note{{previous definition is here}} +void f2(); // expected-error{{redefinition of 'f2' as different kind of symbol}} + +typedef struct s s; +typedef int I; +typedef int I; +typedef I I; + +struct s { }; + +typedef class st { /* ... */ } st; // expected-note{{previous use is here}} +struct st; // expected-error{{use of 'st' with tag type that does not match previous declaration}} |