[PATCH] C++ ICE in check_for_out_of_scope_variable

Roger Sayle roger@eyesopen.com
Tue May 11 15:59:00 GMT 2004


The following patch is a fix for a g++ ICE-on-invalid that I've just
bumped into on mainline.

iter.h:281: error: `_ptrs' was not declared in this scope
iter.h:284: internal compiler error: tree check: expected class 't', have
'x' (error_mark) in check_for_out_of_scope_variable, at cp/name-lookup.c:1148

The line reads TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)), and
although decl is checked for being a valid VAR_DECL, we're missing a
check that the TREE_TYPE isn't error_mark_node.  Fortunately, there's
a convenient place to check for this three or four lines earlier.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all languages except treelang, and regression tested
with a top-level "make -k check" with no new failures.  Reducing a
dejagnu testcase from the proprietary sources would be painfull.

Ok for mainline?


2004-05-11  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.


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	10 May 2004 23:43:35 -0000
*************** check_for_out_of_scope_variable (tree de
*** 1141,1147 ****

    /* If we have already complained about this declaration, there's no
       need to do it again.  */
!   if (DECL_ERROR_REPORTED (decl))
      return decl;

    DECL_ERROR_REPORTED (decl) = 1;
--- 1141,1148 ----

    /* If we have already complained about this declaration, there's no
       need to do it again.  */
!   if (DECL_ERROR_REPORTED (decl)
!       || TREE_TYPE (decl) == error_mark_node)
      return decl;

    DECL_ERROR_REPORTED (decl) = 1;

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



More information about the Gcc-patches mailing list