+2018-05-22 Martin Sebor <msebor@redhat.com>
+
+ PR tree-optimization/85826
+ * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Avoid
+ assuming that a DECL necesarily has a constant size.
+
2018-05-22 Richard Sandiford <richard.sandiford@linaro.org>
PR middle-end/85862
&& 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)
{
+2018-05-22 Martin Sebor <msebor@redhat.com>
+
+ PR tree-optimization/85826
+ * gcc.dg/Wrestrict-17.c: New test.
+
2018-05-22 Richard Sandiford <richard.sandiford@linaro.org>
* gcc.dg/torture/pr85862.c: Rename to...
--- /dev/null
+/* PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on
+ a variable-length struct
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+int f (int n)
+{
+ typedef struct { int a[n]; } S;
+
+ S a;
+ __attribute__ ((noinline)) S g (void) { return a; }
+
+ a.a[0] = 1;
+ a.a[9] = 2;
+
+ S b;
+ b = g ();
+
+ return b.a[0] == 1 && b.a[9] == 2;
+}