]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* gcc-interface/trans.c (fold_constant_decl_in_expr) <ARRAY_REF>: If
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Nov 2015 18:19:57 +0000 (18:19 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Nov 2015 18:19:57 +0000 (18:19 +0000)
the index is not itself constant then bail out.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230558 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c

index 2b9eed4cbe98504a3b176b32606bf32bcc2cb44c..3ffb45e7114c79f89e428ae0696f1737ce58fff5 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (fold_constant_decl_in_expr) <ARRAY_REF>: If
+       the index is not itself constant then bail out.
+
 2015-11-18  Ed Schonberg  <schonberg@adacore.com>
 
        * sem_ch4.adb (Try_Container_Indexing): When constructing the
index eeb2aaca5cffd6b23841a4849c3b7b9746512905..0d100193baa6f25429199d56b4c41208aa973cac 100644 (file)
@@ -975,6 +975,9 @@ fold_constant_decl_in_expr (tree exp)
 
     case ARRAY_REF:
     case ARRAY_RANGE_REF:
+      /* If the index is not itself constant, then nothing can be folded.  */
+      if (!TREE_CONSTANT (TREE_OPERAND (exp, 1)))
+       return exp;
       op0 = fold_constant_decl_in_expr (TREE_OPERAND (exp, 0));
       if (op0 == TREE_OPERAND (exp, 0))
        return exp;