]> granicus.if.org Git - clang/commitdiff
Sema::FinalizeDeclaratorGroup()...make sure we emit an diagnostic for tentative defin...
authorSteve Naroff <snaroff@apple.com>
Fri, 18 Jan 2008 00:39:39 +0000 (00:39 +0000)
committerSteve Naroff <snaroff@apple.com>
Fri, 18 Jan 2008 00:39:39 +0000 (00:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46152 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp
test/Sema/array-constraint.c
test/Sema/deref.c
test/Sema/enum.c
test/Sema/incomplete-decl.c [new file with mode: 0644]

index 9e6dbfe3334c725394411da29bd06c0872fafa52..c2c66a20152a0df24b900e54c85c054be047d29b 100644 (file)
@@ -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.
index df79681d06c5388a278e266856420655abafa07f..8b2ce5eca4cb166e4f663755777c6c18b98f2279 100644 (file)
@@ -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);
 
index 87f1b4862e59fbf7deabf613927f0739c16d1a06..7441584107ce0fa1c933c4fa2b599be815138bee 100644 (file)
@@ -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}}
 }
 
index 169c394c50fa041a5a6fe88e8782071903457891..890b6a505b7278a2b631a4365c4e27fd316f566c 100644 (file)
@@ -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 (file)
index 0000000..e342ab8
--- /dev/null
@@ -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'}}
+}