]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/19991 (Enum not accepted in array-size)
authorMark Mitchell <mark@codesourcery.com>
Mon, 2 May 2005 14:46:48 +0000 (14:46 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 2 May 2005 14:46:48 +0000 (14:46 +0000)
Backport:
2005-02-22  Mark Mitchell  <mark@codesourcery.com>
PR c++/19991
* g++.dg/parse/constant7.C: New test.

From-SVN: r99097

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog

index 51dc307d5e4fcd044ac5a694ec855ab7c25e91e9..6e354ff7363b056a4a716329e25cb904fac6a247 100644 (file)
@@ -1,5 +1,15 @@
-2004-12-22  Mark Mitchell  <mark@codesourcery.com>
+2005-05-01  Mark Mitchell  <mark@codesourcery.com>
 
+       Backport:
+       2005-02-22  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/19991
+       * init.c (decl_constant_value): Iterate if the value of a decl
+       is itself a constant.
+
+2005-05-01  Mark Mitchell  <mark@codesourcery.com>
+
+       Backport:
+        2004-12-22  Mark Mitchell  <mark@codesourcery.com>
        PR c++/18464
        * call.c (build_this): In templates, do not bother with
        build_unary_op.
index 6189f469a7dec1553f88f702259d73cd86d9718c..732d4a0c84d712f78f7b9d9d7038df194e33c05e 100644 (file)
@@ -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;
 }
 \f
index b963065c0adfd3567ca3f3ef062a547f7231f9a8..990f45f2e620dcb95a73f62c8819d18d4ce66a6a 100644 (file)
@@ -1,10 +1,19 @@
+2005-05-01  Mark Mitchell  <mark@codesourcery.com>
+
+       Backport:
+       2005-02-22  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/19991
+       * g++.dg/parse/constant7.C: New test.
+
 2005-05-02  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/titype-1.c: Fix dg-error target regexp.
        * gcc.dg/uninit-C.c: Likewise.
 
-2004-12-22  Mark Mitchell  <mark@codesourcery.com>
+2005-05-01  Mark Mitchell  <mark@codesourcery.com>
 
+       Backport:
+       2004-12-22  Mark Mitchell  <mark@codesourcery.com>
        PR c++/18464
        * g++.dg/template/cond5.C: New test.