diff options
author | Steve Naroff <snaroff@apple.com> | 2008-01-18 00:39:39 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-01-18 00:39:39 +0000 |
commit | d3cd1e56d19474ac785e54c3915d82d2ad7f7fa9 (patch) | |
tree | 7c6f28f0cb9ffd2e65ed2d2e2646db271a36feb9 | |
parent | 51f5499420e3e2344c1e6c3eff4764c4ec0b47ca (diff) |
Sema::FinalizeDeclaratorGroup()...make sure we emit an diagnostic for tentative definitions with incomplete types. Touch up all test cases that are effected.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46152 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | test/Sema/array-constraint.c | 3 | ||||
-rw-r--r-- | test/Sema/deref.c | 2 | ||||
-rw-r--r-- | test/Sema/enum.c | 4 | ||||
-rw-r--r-- | test/Sema/incomplete-decl.c | 15 |
5 files changed, 22 insertions, 5 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 9e6dbfe333..c2c66a2015 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -853,7 +853,8 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) { // storage-class specifier or with the storage-class specifier "static", // constitutes a tentative definition. Note: A tentative definition with // external linkage is valid (C99 6.2.2p5). - if (FVD && !FVD->getInit() && FVD->getStorageClass() == VarDecl::Static) { + if (FVD && !FVD->getInit() && (FVD->getStorageClass() == VarDecl::Static || + FVD->getStorageClass() == VarDecl::None)) { // C99 6.9.2p3: If the declaration of an identifier for an object is // a tentative definition and has internal linkage (C99 6.2.2p3), the // declared type shall not be an incomplete type. diff --git a/test/Sema/array-constraint.c b/test/Sema/array-constraint.c index df79681d06..8b2ce5eca4 100644 --- a/test/Sema/array-constraint.c +++ b/test/Sema/array-constraint.c @@ -24,7 +24,8 @@ struct vari *func(struct vari a[]) { // expected-error {{'struct vari' may not b return a; } -int foo[](void); // expected-error {{'foo' declared as array of functions}} +int foo[](void); // expected-error {{variable has incomplete type 'int (*[])(void)'}} expected-error {{'foo' declared as array of functions}} +int foo2[1](void); // expected-error {{'foo2' declared as array of functions}} typedef int (*pfunc)(void); diff --git a/test/Sema/deref.c b/test/Sema/deref.c index 87f1b4862e..7441584107 100644 --- a/test/Sema/deref.c +++ b/test/Sema/deref.c @@ -17,6 +17,6 @@ void foo2 (void) void foo3 (void) { void* x = 0; - void* y = &*x; // expected-error {{invalid lvalue in address expression}} + void* y = &*x; // expected-error {{address expression must be an lvalue or a function designator}} } diff --git a/test/Sema/enum.c b/test/Sema/enum.c index 169c394c50..890b6a505b 100644 --- a/test/Sema/enum.c +++ b/test/Sema/enum.c @@ -22,9 +22,9 @@ int test() { return sizeof(enum e) ; } -enum gccForwardEnumExtension ve; // expected-warning {{ISO C forbids forward references to 'enum' types}} +enum gccForwardEnumExtension ve; // expected-error {{variable has incomplete type 'enum gccForwardEnumExtension'}} expected-warning{{ISO C forbids forward references to 'enum' types}} int test2(int i) { - ve + i; // expected-error{{invalid operands to binary expression ('enum gccForwardEnumExtension' and 'int')}} + ve + i; } diff --git a/test/Sema/incomplete-decl.c b/test/Sema/incomplete-decl.c new file mode 100644 index 0000000000..e342ab8b70 --- /dev/null +++ b/test/Sema/incomplete-decl.c @@ -0,0 +1,15 @@ +// RUN: clang -fsyntax-only -verify %s + +void b; // expected-error {{variable has incomplete type 'void'}} +struct foo f; // expected-error {{variable has incomplete type 'struct foo'}} + +static void c; // expected-error {{variable has incomplete type 'void'}} +static struct foo g; // expected-error {{variable has incomplete type 'struct foo'}} + +extern void d; +extern struct foo e; + +void func() { + void b; // expected-error {{variable has incomplete type 'void'}} + struct foo f; // expected-error {{variable has incomplete type 'struct foo'}} +} |