From a239279ee574a15ed79d27b48f835c3db45a593f Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 18 Nov 2015 18:19:57 +0000 Subject: [PATCH] trans.c (fold_constant_decl_in_expr): If the index is not itself constant then bail out. * gcc-interface/trans.c (fold_constant_decl_in_expr) : If the index is not itself constant then bail out. From-SVN: r230558 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/gcc-interface/trans.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 2b9eed4cbe9..3ffb45e7114 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2015-11-18 Eric Botcazou + + * gcc-interface/trans.c (fold_constant_decl_in_expr) : If + the index is not itself constant then bail out. + 2015-11-18 Ed Schonberg * sem_ch4.adb (Try_Container_Indexing): When constructing the diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index eeb2aaca5cf..0d100193baa 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -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; -- 2.30.2