This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] C++ ICE in check_for_out_of_scope_variable


On Wed, 12 May 2004, Jason Merrill wrote:
> > On Tue, 11 May 2004, Roger Sayle wrote:
> >> The following patch is a fix for a g++ ICE-on-invalid that I've just
> >> bumped into on mainline.
>
> The patch is OK.

Hi Jason,

Sorry to ask you to rereview this patch, but just before commiting
I double checked that the recent tree-ssa changes hadn't adversely
affected the patch, and indeed they've exposed a second ICE with
the same testcase.  Technically it would have been a regression :>

The following patch also fixes this second ICE, so that Wolfgang's
reduced testcase passes.  The following patch has been tested on
i686-pc-linux-gnu against mainline with a full "make bootstrap",
all current languages, and regression tested with a top-level
"make -k check" with no new failures.

Still Ok for mainline?


2004-05-14  Roger Sayle  <roger@eyesopen.com>

	* name-lookup.c (check_for_out_of_scope_variable): Avoid ICE by
	returning when TREE_TYPE is error_mark_node.
	* typeck.c (require_complete_type): Return error_mark_node if
	value's type is an error_mark_node.

2004-05-14  Wolfgang Bangerth  <bangerth@dealii.org>

	* g++.dg/lookup/forscope2.C: New test case.


Index: name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.51
diff -c -3 -p -r1.51 name-lookup.c
*** name-lookup.c	22 Apr 2004 05:10:21 -0000	1.51
--- name-lookup.c	14 May 2004 17:54:12 -0000
*************** check_for_out_of_scope_variable (tree de
*** 1145,1150 ****
--- 1145,1154 ----
      return decl;

    DECL_ERROR_REPORTED (decl) = 1;
+
+   if (TREE_TYPE (decl) == error_mark_node)
+     return decl;
+
    if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
      {
        error ("name lookup of `%D' changed for new ISO `for' scoping",
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.541
diff -c -3 -p -r1.541 typeck.c
*** typeck.c	13 May 2004 06:40:22 -0000	1.541
--- typeck.c	14 May 2004 17:54:13 -0000
*************** require_complete_type (tree value)
*** 96,101 ****
--- 96,104 ----
    else
      type = TREE_TYPE (value);

+   if (type == error_mark_node)
+     return error_mark_node;
+
    /* First, detect a valid value with a complete type.  */
    if (COMPLETE_TYPE_P (type))
      return value;


// { dg-do compile }

struct S {
  void foo() {
     for (_ptr; ;) {}  // { dg-error "not declared" }
     _ptr = 0;
    }
};


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]