]> granicus.if.org Git - clang/commitdiff
Fix PR1863: an assertion due to not setting a location on return from
authorChris Lattner <sabre@nondot.org>
Tue, 18 Dec 2007 07:03:30 +0000 (07:03 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 18 Dec 2007 07:03:30 +0000 (07:03 +0000)
this method.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45153 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Type.cpp

index 63f3589769552e9096f5f652f6a6d62a2654be41..ccd4630843d7496f3bf2f4ec60d7d88d56a88e62 100644 (file)
@@ -449,9 +449,13 @@ bool Type::isAggregateType() const {
 // The only variable size types are auto arrays within a function. Structures 
 // cannot contain a VLA member. They can have a flexible array member, however
 // the structure is still constant size (C99 6.7.2.1p16).
-bool Type::isConstantSizeType(ASTContext &Ctx, SourceLocation *loc) const {
-  if (isa<VariableArrayType>(CanonicalType))
+bool Type::isConstantSizeType(ASTContext &Ctx, SourceLocation *Loc) const {
+  assert(!isIncompleteType() && "This doesn't make sense for incomplete types");
+  if (const VariableArrayType *VAT =dyn_cast<VariableArrayType>(CanonicalType)){
+    // The VAT must have a size, as it is known to be complete.
+    if (Loc) *Loc = VAT->getSizeExpr()->getLocStart();
     return false;
+  }
   return true;
 }