Fix an assertion failure regression in isDesignatorAtObjectEnd for
__builtin_object_size with incomplete array type in struct
The commit r316245 introduced a regression that causes an assertion failure when
Clang tries to cast an IncompleteArrayType to a PointerType when evaluating
__builtin_object_size.
rdar://36094951
Differential Revision: https://reviews.llvm.org/D41405
llvm-svn: 321222
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7b0b731..8d9b3c3 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -7420,7 +7420,10 @@
// If we don't know the array bound, conservatively assume we're looking at
// the final array element.
++I;
- BaseType = BaseType->castAs<PointerType>()->getPointeeType();
+ if (BaseType->isIncompleteArrayType())
+ BaseType = Ctx.getAsArrayType(BaseType)->getElementType();
+ else
+ BaseType = BaseType->castAs<PointerType>()->getPointeeType();
}
for (unsigned E = LVal.Designator.Entries.size(); I != E; ++I) {