From: Mark Mitchell Date: Mon, 2 May 2005 14:46:48 +0000 (+0000) Subject: backport: re PR c++/19991 (Enum not accepted in array-size) X-Git-Tag: releases/gcc-3.4.4~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eeda27a5d4953672be3f7376b6012bbe720ca240;p=thirdparty%2Fgcc.git backport: re PR c++/19991 (Enum not accepted in array-size) Backport: 2005-02-22 Mark Mitchell PR c++/19991 * g++.dg/parse/constant7.C: New test. From-SVN: r99097 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 51dc307d5e4f..6e354ff7363b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,15 @@ -2004-12-22 Mark Mitchell +2005-05-01 Mark Mitchell + Backport: + 2005-02-22 Mark Mitchell + PR c++/19991 + * init.c (decl_constant_value): Iterate if the value of a decl + is itself a constant. + +2005-05-01 Mark Mitchell + + Backport: + 2004-12-22 Mark Mitchell PR c++/18464 * call.c (build_this): In templates, do not bother with build_unary_op. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 6189f469a7de..732d4a0c84d7 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1623,21 +1623,23 @@ decl_constant_value (tree decl) TREE_OPERAND (decl, 0), d1, d2); } - if (DECL_P (decl) - && (/* Enumeration constants are constant. */ - TREE_CODE (decl) == CONST_DECL - /* And so are variables with a 'const' type -- unless they - are also 'volatile'. */ - || CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl))) - && DECL_INITIAL (decl) - && DECL_INITIAL (decl) != error_mark_node - /* This is invalid if initial value is not constant. - If it has either a function call, a memory reference, - or a variable, then re-evaluating it could give different results. */ - && TREE_CONSTANT (DECL_INITIAL (decl)) - /* Check for cases where this is sub-optimal, even though valid. */ - && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR) - return DECL_INITIAL (decl); + while (DECL_P (decl) + && (/* Enumeration constants are constant. */ + TREE_CODE (decl) == CONST_DECL + /* And so are variables with a 'const' type -- unless they + are also 'volatile'. */ + || CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl))) + && DECL_INITIAL (decl) + && DECL_INITIAL (decl) != error_mark_node + /* This is invalid if initial value is not constant. If it + has either a function call, a memory reference, or a + variable, then re-evaluating it could give different + results. */ + && TREE_CONSTANT (DECL_INITIAL (decl)) + /* Check for cases where this is sub-optimal, even though + valid. */ + && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR) + decl = DECL_INITIAL (decl); return decl; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b963065c0adf..990f45f2e620 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,10 +1,19 @@ +2005-05-01 Mark Mitchell + + Backport: + 2005-02-22 Mark Mitchell + PR c++/19991 + * g++.dg/parse/constant7.C: New test. + 2005-05-02 Eric Botcazou * gcc.dg/titype-1.c: Fix dg-error target regexp. * gcc.dg/uninit-C.c: Likewise. -2004-12-22 Mark Mitchell +2005-05-01 Mark Mitchell + Backport: + 2004-12-22 Mark Mitchell PR c++/18464 * g++.dg/template/cond5.C: New test.