[PATCH] D41405: Fix an assertion failure regression in isDesignatorAtObjectEnd for __builtin_object_size with incomplete array type in struct
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 20 13:04:39 PST 2017
This revision was automatically updated to reflect the committed changes.
arphaman marked 2 inline comments as done.
Closed by commit rC321222: Fix an assertion failure regression in isDesignatorAtObjectEnd for (authored by arphaman, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D41405?vs=127438&id=127778#toc
Repository:
rC Clang
https://reviews.llvm.org/D41405
Files:
lib/AST/ExprConstant.cpp
test/Sema/builtin-object-size.c
Index: lib/AST/ExprConstant.cpp
===================================================================
--- lib/AST/ExprConstant.cpp
+++ 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) {
Index: test/Sema/builtin-object-size.c
===================================================================
--- test/Sema/builtin-object-size.c
+++ test/Sema/builtin-object-size.c
@@ -91,3 +91,22 @@
return n;
}
+
+typedef struct {
+ char string[512];
+} NestedArrayStruct;
+
+typedef struct {
+ int x;
+ NestedArrayStruct session[];
+} IncompleteArrayStruct;
+
+void rd36094951_IAS_builtin_object_size_assertion(IncompleteArrayStruct *p) {
+#define rd36094951_CHECK(mode) \
+ __builtin___strlcpy_chk(p->session[0].string, "ab", 2, \
+ __builtin_object_size(p->session[0].string, mode))
+ rd36094951_CHECK(0);
+ rd36094951_CHECK(1);
+ rd36094951_CHECK(2);
+ rd36094951_CHECK(3);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41405.127778.patch
Type: text/x-patch
Size: 1425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171220/fa667db2/attachment.bin>
More information about the cfe-commits
mailing list