This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR c++/9559
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 1 Jul 2003 00:19:32 -0700
- Subject: C++ PATCH: PR c++/9559
- Reply-to: mark at codesourcery dot com
This patch removes some utterly bogus code -- we should not be
building complex expressions involving the error_mark_node. The
comment in the old code is irrelevant; it's not a big deal if
decl_constant_value gets slighty confused and it's not clear to me
that it *will* get confused.
Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
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-07-01 Mark Mitchell <mark@codesourcery.com>
PR c++/9559
* g++.dg/init/static1.C: New test.
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.632
diff -c -5 -p -r1.632 decl2.c
*** cp/decl2.c 24 Jun 2003 11:54:01 -0000 1.632
--- cp/decl2.c 1 Jul 2003 03:57:23 -0000
*************** grokfield (tree declarator, tree declspe
*** 949,964 ****
init = DECL_INITIAL (init);
else if (TREE_READONLY_DECL_P (init))
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))
{
/* We can allow references to things that are effectively
static, since references are initialized with the
address. */
if (TREE_CODE (TREE_TYPE (value)) != REFERENCE_TYPE
--- 949,959 ----
init = DECL_INITIAL (init);
else if (TREE_READONLY_DECL_P (init))
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 && ! TREE_CONSTANT (init))
{
/* We can allow references to things that are effectively
static, since references are initialized with the
address. */
if (TREE_CODE (TREE_TYPE (value)) != REFERENCE_TYPE
Index: testsuite/g++.dg/init/static1.C
===================================================================
RCS file: testsuite/g++.dg/init/static1.C
diff -N testsuite/g++.dg/init/static1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/static1.C 1 Jul 2003 03:57:23 -0000
***************
*** 0 ****
--- 1,4 ----
+ struct A {
+ static const int size = BOGUS; // { dg-error "" }
+ };
+ const int A::size;