diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-12-28 15:28:59 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-12-28 15:28:59 +0000 |
commit | a2b5e31cb19f4fd4680e7230cd5497f5ef09a438 (patch) | |
tree | 6fd57f409f89d403fd1223128378c58cf61cbd3c /clang/test | |
parent | 85cd7bac29a05dbab8b784eec5585ae1aa9564d7 (diff) | |
download | bcm5719-llvm-a2b5e31cb19f4fd4680e7230cd5497f5ef09a438.tar.gz bcm5719-llvm-a2b5e31cb19f4fd4680e7230cd5497f5ef09a438.zip |
Diagnose declarations that don't declare anything, and fix PR3020.
Examples:
int;
typedef int;
llvm-svn: 61454
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Parser/cxx-template-decl.cpp | 10 | ||||
-rw-r--r-- | clang/test/Sema/decl-invalid.c | 9 | ||||
-rw-r--r-- | clang/test/SemaCXX/class.cpp | 4 |
3 files changed, 18 insertions, 5 deletions
diff --git a/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp index 53813776e77..79b04cfc797 100644 --- a/clang/test/Parser/cxx-template-decl.cpp +++ b/clang/test/Parser/cxx-template-decl.cpp @@ -5,10 +5,12 @@ export class foo { }; // expected-error {{expected template}} template x; // expected-error {{expected '<' after 'template'}} export template x; // expected-error {{expected '<' after 'template'}} \ // expected-note {{exported templates are unsupported}} -template < ; // expected-error {{parse error}} -template <template X> ; // expected-error {{expected '<' after 'template'}} -template <template <typename> > ; // expected-error {{expected 'class' before '>'}} -template <template <typename> Foo> ; // expected-error {{expected 'class' before 'Foo'}} +// See Sema::ParsedFreeStandingDeclSpec about the double diagnostic. This is +// because ParseNonTypeTemplateParameter starts parsing a DeclSpec. +template < ; // expected-error {{parse error}} expected-error {{declaration does not declare anything}} +template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} +template <template <typename> > struct Err2; // expected-error {{expected 'class' before '>'}} +template <template <typename> Foo> struct Err3; // expected-error {{expected 'class' before 'Foo'}} // Template function declarations template <typename T> void foo(); diff --git a/clang/test/Sema/decl-invalid.c b/clang/test/Sema/decl-invalid.c index 767d6e6ab40..78a9ee1d4bf 100644 --- a/clang/test/Sema/decl-invalid.c +++ b/clang/test/Sema/decl-invalid.c @@ -1,6 +1,7 @@ // RUN: clang %s -fsyntax-only -verify -typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anonymous union must be a definition}} +// See Sema::ParsedFreeStandingDeclSpec about the double diagnostic +typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anonymous union must be a definition}} expected-error {{declaration does not declare anything}} // PR2017 @@ -9,3 +10,9 @@ int a() { int r[x()]; // expected-error {{size of array has non-integer type 'void'}} } +int; // expected-error {{declaration does not declare anything}} +typedef int; // expected-error {{declaration does not declare anything}} +const int; // expected-error {{declaration does not declare anything}} +struct; // expected-error {{declaration of anonymous struct must be a definition}} // expected-error {{declaration does not declare anything}} +typedef int I; +I; // expected-error {{declaration does not declare anything}} diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp index b7d1ca34dcf..7e06415a09d 100644 --- a/clang/test/SemaCXX/class.cpp +++ b/clang/test/SemaCXX/class.cpp @@ -100,4 +100,8 @@ mutable void gfn(); // expected-error {{illegal storage class on function}} void ogfn() { mutable int ml; // expected-error {{error: 'mutable' can only be applied to member variables}} + + // PR3020: This used to crash due to double ownership of C4. + struct C4; + C4; // expected-error {{declaration does not declare anything}} } |