diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-04-26 21:57:51 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-04-26 21:57:51 +0000 |
commit | f91f5c8a66ffd812f61819836529f8ad437f7e2b (patch) | |
tree | 1c409fa493e1bda75035839f8b3a64fdffb0d570 /lib | |
parent | de1b60a9868f80f0872ed05d78df3b40a10ba5ca (diff) |
Add a bit more handling for declarations like "int a[*]".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70162 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Type.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index a94310bbdf..0331bbf40d 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -37,7 +37,8 @@ void Type::Destroy(ASTContext& C) { } void VariableArrayType::Destroy(ASTContext& C) { - SizeExpr->Destroy(C); + if (SizeExpr) + SizeExpr->Destroy(C); this->~VariableArrayType(); C.Deallocate(this); } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 883cf221fb..5df0aecd8f 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -500,7 +500,10 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, } llvm::APSInt ConstVal(32); if (!ArraySize) { - T = Context.getIncompleteArrayType(T, ASM, Quals); + if (ASM == ArrayType::Star) + T = Context.getVariableArrayType(T, 0, ASM, Quals); + else + T = Context.getIncompleteArrayType(T, ASM, Quals); } else if (ArraySize->isValueDependent()) { T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals); } else if (!ArraySize->isIntegerConstantExpr(ConstVal, Context) || @@ -687,6 +690,15 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) { ASM = ArrayType::Static; else ASM = ArrayType::Normal; + if (ASM == ArrayType::Star && + D.getContext() != Declarator::PrototypeContext) { + // FIXME: This check isn't quite right: it allows star in prototypes + // for function definitions, and disallows some edge cases detailed + // in http://gcc.gnu.org/ml/gcc-patches/2009-02/msg00133.html + Diag(DeclType.Loc, diag::err_array_star_outside_prototype); + ASM = ArrayType::Normal; + D.setInvalidType(true); + } T = BuildArrayType(T, ASM, ArraySize, ATI.TypeQuals, DeclType.Loc, Name); break; } |