aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaDecl.cpp7
-rw-r--r--lib/Sema/SemaType.cpp6
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index c958dd1027..2d0251cc14 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -951,7 +951,7 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) {
// Block scope. C99 6.7p7: If an identifier for an object is declared with
// no linkage (C99 6.2.2p6), the type for the object shall be complete...
if (BVD && IDecl->getStorageClass() != VarDecl::Extern) {
- if (T->isIncompleteType()) {
+ if (T->isIncompleteType() && !IDecl->isInvalidDecl()) {
Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type,
T.getAsString());
IDecl->setInvalidDecl();
@@ -967,7 +967,7 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) {
if (T->isIncompleteArrayType()) {
// C99 6.9.2 (p2, p5): Implicit initialization causes an incomplete
// array to be completed. Don't issue a diagnostic.
- } else if (T->isIncompleteType()) {
+ } else if (T->isIncompleteType() && !IDecl->isInvalidDecl()) {
// 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.
@@ -1100,7 +1100,8 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
// C99 6.7.5.3p4: the parameters in a parameter type list in a function
// declarator that is part of a function definition of that function
// shall not have incomplete type.
- if (parmDecl->getType()->isIncompleteType()) {
+ if (parmDecl->getType()->isIncompleteType() &&
+ !parmDecl->isInvalidDecl()) {
Diag(parmDecl->getLocation(), diag::err_typecheck_decl_incomplete_type,
parmDecl->getType().getAsString());
parmDecl->setInvalidDecl();
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index d4cb979563..ad9d138f91 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -203,7 +203,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
DeclType.Ref.AttrList = ProcessTypeAttributes(T, AL);
break;
case DeclaratorChunk::Array: {
- const DeclaratorChunk::ArrayTypeInfo &ATI = DeclType.Arr;
+ DeclaratorChunk::ArrayTypeInfo &ATI = DeclType.Arr;
Expr *ArraySize = static_cast<Expr*>(ATI.NumElts);
ArrayType::ArraySizeModifier ASM;
if (ATI.isStar)
@@ -246,9 +246,11 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
Diag(ArraySize->getLocStart(), diag::err_array_size_non_int,
ArraySize->getType().getAsString(), ArraySize->getSourceRange());
D.setInvalidType(true);
+ delete ArraySize;
+ ATI.NumElts = ArraySize = 0;
}
llvm::APSInt ConstVal(32);
- // If no expression was provided, we consider it a VLA.
+ // If no expression was provided, we consider it an incomplete array.
if (!ArraySize) {
T = Context.getIncompleteArrayType(T, ASM, ATI.TypeQuals);
} else if (!ArraySize->isIntegerConstantExpr(ConstVal, Context)) {