summaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-warn-restrict.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-05-22 15:22:16 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-05-22 09:22:16 -0600
commit9f855c10d6be14e4ac73fc55625d4799ca939cf8 (patch)
tree26f442f9bb35bd3f8a13db2039ee7a8396748413 /gcc/gimple-ssa-warn-restrict.c
parentf141b40a181eea1546d0b6930c4eb386cd28241f (diff)
PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on
PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on a variable-length struct gcc/ChangeLog: PR tree-optimization/85826 * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Avoid assuming that a DECL necesarily has a constant size. gcc/testsuite/ChangeLog: PR tree-optimization/85826 * gcc.dg/Wrestrict-17.c: New test. From-SVN: r260537
Diffstat (limited to 'gcc/gimple-ssa-warn-restrict.c')
-rw-r--r--gcc/gimple-ssa-warn-restrict.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c
index 9f23f57c426..637ed3cc290 100644
--- a/gcc/gimple-ssa-warn-restrict.c
+++ b/gcc/gimple-ssa-warn-restrict.c
@@ -278,7 +278,10 @@ builtin_memref::builtin_memref (tree expr, tree size)
&& array_at_struct_end_p (ref))
; /* Use the maximum possible offset for last member arrays. */
else if (tree basesize = TYPE_SIZE_UNIT (basetype))
- maxoff = wi::to_offset (basesize);
+ if (TREE_CODE (basesize) == INTEGER_CST)
+ /* Size could be non-constant for a variable-length type such
+ as a struct with a VLA member (a GCC extension). */
+ maxoff = wi::to_offset (basesize);
if (offrange[0] >= 0)
{