forked from OSchip/llvm-project
Sema::FinalizeDeclaratorGroup()...make sure we emit an diagnostic for tentative definitions with incomplete types. Touch up all test cases that are effected.
llvm-svn: 46152
This commit is contained in:
parent
1989d2569b
commit
b716fbab44
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'}}
|
||||
}
|
Loading…
Reference in New Issue