re PR c++/9559 (ICE with invalid initialization of a static const member)
authorMark Mitchell <mark@codesourcery.com>
Tue, 1 Jul 2003 07:17:03 +0000 (07:17 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 1 Jul 2003 07:17:03 +0000 (07:17 +0000)
PR c++/9559
* decl2.c (grokfield): Do not build NOP_EXPRs around the
error_mark_node.

PR c++/9559
* g++.dg/init/static1.C: New test.

From-SVN: r68764

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/static1.C [new file with mode: 0644]

index 040582dc6cd8999a37a954bd10d71f682486b92c..45a879d590d07ada1d33bc827a497f2a27818a46 100644 (file)
@@ -1,3 +1,9 @@
+2003-07-01  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9559
+       * decl2.c (grokfield): Do not build NOP_EXPRs around the
+       error_mark_node.
+
 2003-06-30  Neil Booth  <neil@daikokuya.co.uk>
 
        * Make-lang.in: Update.
index 9a96000046899576495f60d24620f29d9d78b5c8..d27bacd6018bda38aa8123f060789d60c53ce3be 100644 (file)
@@ -951,12 +951,7 @@ grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree,
                init = decl_constant_value (init);
              else if (TREE_CODE (init) == CONSTRUCTOR)
                init = digest_init (TREE_TYPE (value), init, (tree *)0);
-             if (init == error_mark_node)
-               /* We must make this look different than `error_mark_node'
-                  because `decl_const_value' would mis-interpret it
-                  as only meaning that this VAR_DECL is defined.  */
-               init = build1 (NOP_EXPR, TREE_TYPE (value), init);
-             else if (! TREE_CONSTANT (init))
+             if (init != error_mark_node && ! TREE_CONSTANT (init))
                {
                  /* We can allow references to things that are effectively
                     static, since references are initialized with the
index 5d0d27404b246c8aa5a1baa1c2c1a7bd280355c5..cf664e4dd955f238aa4078ae4b2415f2b9873a3b 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-01  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9559
+       * g++.dg/init/static1.C: New test.
+
 2003-06-30  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        * Changelog: Remove ">>>>>>>" from previous change.
diff --git a/gcc/testsuite/g++.dg/init/static1.C b/gcc/testsuite/g++.dg/init/static1.C
new file mode 100644 (file)
index 0000000..7609215
--- /dev/null
@@ -0,0 +1,4 @@
+struct A {
+  static const int size = BOGUS; // { dg-error "" }
+};
+const int A::size;