forked from OSchip/llvm-project
PR3461: reject initializer for incomplete type. Based on patch by Tim
Northover. llvm-svn: 68991
This commit is contained in:
parent
c0a4ea0c02
commit
337cd3a536
|
@ -2396,6 +2396,13 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!VDecl->getType()->isArrayType() &&
|
||||
RequireCompleteType(VDecl->getLocation(), VDecl->getType(),
|
||||
diag::err_typecheck_decl_incomplete_type)) {
|
||||
RealDecl->setInvalidDecl();
|
||||
return;
|
||||
}
|
||||
|
||||
const VarDecl *Def = 0;
|
||||
if (VDecl->getDefinition(Def)) {
|
||||
Diag(VDecl->getLocation(), diag::err_redefinition)
|
||||
|
|
|
@ -23,3 +23,8 @@ void func() {
|
|||
int h[];
|
||||
int (*i)[] = &h+1; // expected-error {{arithmetic on pointer to incomplete type 'int (*)[]'}}
|
||||
|
||||
struct bar j = {1}; // expected-error {{variable has incomplete type 'struct bar'}} \
|
||||
expected-note {{forward declaration of 'struct bar'}}
|
||||
struct bar k;
|
||||
struct bar { int a; };
|
||||
|
||||
|
|
Loading…
Reference in New Issue