re PR middle-end/81737 (164.gzip in SPEC CPU 2000 failed to build)
authorMarek Polacek <polacek@redhat.com>
Mon, 7 Aug 2017 09:13:02 +0000 (09:13 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 7 Aug 2017 09:13:02 +0000 (09:13 +0000)
PR middle-end/81737
* fold-const.c (fold_indirect_ref_1): Check type_domain.

* gcc.dg/pr81737.c: New test.

From-SVN: r250912

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr81737.c [new file with mode: 0644]

index 880a3c89a3f4f53cc6eeb08d8aec927eff89ed5c..8fbb8c4d8b5728ec831b52b2472dfdb8c559cddc 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-07  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/81737
+       * fold-const.c (fold_indirect_ref_1): Check type_domain.
+
 2017-08-07  Martin Liska  <mliska@suse.cz>
 
        * attribs.h (canonicalize_attr_name): New function.
index d563ba767668ddfcfbd2d0ea7c17550416d80b5b..8eaea6cce3a57d54df3e701530748654b679df33 100644 (file)
@@ -14107,8 +14107,10 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
                   && type == TREE_TYPE (op00type))
            {
              tree type_domain = TYPE_DOMAIN (op00type);
-             tree min = TYPE_MIN_VALUE (type_domain);
-             if (min && TREE_CODE (min) == INTEGER_CST)
+             tree min;
+             if (type_domain != NULL_TREE
+                 && (min = TYPE_MIN_VALUE (type_domain))
+                 && TREE_CODE (min) == INTEGER_CST)
                {
                  offset_int off = wi::to_offset (op01);
                  offset_int el_sz = wi::to_offset (TYPE_SIZE_UNIT (type));
index 1e5f70508263a39598b2ff9ba0b2baf34ffe7279..bf161a311414b8b243b3adf4ed1d52f8708f8a64 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-07  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/81737
+       * gcc.dg/pr81737.c: New test.
+
 2017-08-07  Martin Liska  <mliska@suse.cz>
 
        * g++.dg/cpp0x/pr65558.C: Update scanned pattern.
diff --git a/gcc/testsuite/gcc.dg/pr81737.c b/gcc/testsuite/gcc.dg/pr81737.c
new file mode 100644 (file)
index 0000000..4933589
--- /dev/null
@@ -0,0 +1,6 @@
+/* PR middle-end/81737 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+extern int a[];
+void fn1() { (a + 0)[1]; }