[cfe-commits] r46152 - in /cfe/trunk: Sema/SemaDecl.cpp test/Sema/array-constraint.c test/Sema/deref.c test/Sema/enum.c test/Sema/incomplete-decl.c

Steve Naroff snaroff at apple.com
Thu Jan 17 16:39:39 PST 2008


Author: snaroff
Date: Thu Jan 17 18:39:39 2008
New Revision: 46152

URL: http://llvm.org/viewvc/llvm-project?rev=46152&view=rev
Log:

Sema::FinalizeDeclaratorGroup()...make sure we emit an diagnostic for tentative definitions with incomplete types. Touch up all test cases that are effected.


Added:
    cfe/trunk/test/Sema/incomplete-decl.c
Modified:
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/array-constraint.c
    cfe/trunk/test/Sema/deref.c
    cfe/trunk/test/Sema/enum.c

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=46152&r1=46151&r2=46152&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Thu Jan 17 18:39:39 2008
@@ -853,7 +853,8 @@
     // 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.

Modified: cfe/trunk/test/Sema/array-constraint.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/array-constraint.c?rev=46152&r1=46151&r2=46152&view=diff

==============================================================================
--- cfe/trunk/test/Sema/array-constraint.c (original)
+++ cfe/trunk/test/Sema/array-constraint.c Thu Jan 17 18:39:39 2008
@@ -24,7 +24,8 @@
   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);
 

Modified: cfe/trunk/test/Sema/deref.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/deref.c?rev=46152&r1=46151&r2=46152&view=diff

==============================================================================
--- cfe/trunk/test/Sema/deref.c (original)
+++ cfe/trunk/test/Sema/deref.c Thu Jan 17 18:39:39 2008
@@ -17,6 +17,6 @@
 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}}
 }
 

Modified: cfe/trunk/test/Sema/enum.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum.c?rev=46152&r1=46151&r2=46152&view=diff

==============================================================================
--- cfe/trunk/test/Sema/enum.c (original)
+++ cfe/trunk/test/Sema/enum.c Thu Jan 17 18:39:39 2008
@@ -22,9 +22,9 @@
   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;
 }

Added: cfe/trunk/test/Sema/incomplete-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/incomplete-decl.c?rev=46152&view=auto

==============================================================================
--- cfe/trunk/test/Sema/incomplete-decl.c (added)
+++ cfe/trunk/test/Sema/incomplete-decl.c Thu Jan 17 18:39:39 2008
@@ -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'}}
+}





More information about the cfe-commits mailing list