g++-2.96: ICE in `fixup_var_refs_1'

Mark Mitchell mark@codesourcery.com
Thu Sep 30 19:57:00 GMT 1999


Here's the patch.  This patch also postpones the assignment of RTL for
anonymous unions until RTL-generation time, which makes sense.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-09-23  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (DECL_ANON_UNION_ELEMS): New macro.
	* decl2.c (finish_anon_union): Set DECL_ANON_UNION_ELEMS.
	Don't call expand_anon_union_decl here
	* semantics.c (exapnd_stmt): Call it here, instead.
	* typeck.c (mark_addressable): Addressed variables are implicitly
	used.
	
Index: testsuite/g++.old-deja/g++.eh/crash2.C
===================================================================
RCS file: crash2.C
diff -N crash2.C
*** /dev/null	Sat Dec  5 20:30:03 1998
--- crash2.C	Thu Sep 23 17:59:44 1999
***************
*** 0 ****
--- 1,27 ----
+ // Build don't link:
+ // Origin: Thomas Kunert <kunert@physik.tu-dresden.de>
+ // Special g++ Options: -O
+ 
+ struct C {
+     ~C();
+ };    
+ 
+ struct R {
+     bool empty() const;
+     C m_;
+ };
+ 
+ struct R1 {
+     R1( const R& a );
+   ~R1 ();
+     C m_;
+ };
+ 
+ R1 get_empty();
+ 
+ R1::R1( const R& a ) :
+     m_( a.empty() ? get_empty().m_ : C() )
+ {}
+ 
+ void qnorm( const R & r)
+ { R1 n( r ); } 
Index: cp/cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.312
diff -c -p -r1.312 cp-tree.h
*** cp-tree.h	1999/09/21 14:40:11	1.312
--- cp-tree.h	1999/09/24 00:59:28
*************** Boston, MA 02111-1307, USA.  */
*** 116,123 ****
       calling the function.  The TREE_VALUE is the declaration for the 
       virtual function itself.  When CLASSTYPE_COM_INTERFACE_P does not
       hold, the first entry does not have a TREE_VALUE; it is just an
!      offset.  */ 
  
  /* Language-dependent contents of an identifier.  */
  
  struct lang_identifier
--- 116,126 ----
       calling the function.  The TREE_VALUE is the declaration for the 
       virtual function itself.  When CLASSTYPE_COM_INTERFACE_P does not
       hold, the first entry does not have a TREE_VALUE; it is just an
!      offset.
  
+    DECL_ARGUMENTS
+      For a VAR_DECL this is DECL_ANON_UNION_ELEMS.  */
+ 
  /* Language-dependent contents of an identifier.  */
  
  struct lang_identifier
*************** extern int flag_new_for_scope;
*** 2185,2190 ****
--- 2188,2195 ----
    (CLASS_TYPE_P (NODE) && TYPE_LANG_SPECIFIC (NODE)->anon_aggr)
  #define SET_ANON_AGGR_TYPE_P(NODE)			\
    (TYPE_LANG_SPECIFIC (NODE)->anon_aggr = 1)
+ 
+ #define DECL_ANON_UNION_ELEMS(NODE) DECL_ARGUMENTS ((NODE))
  
  #define UNKNOWN_TYPE LANG_TYPE
  
Index: cp/decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.264
diff -c -p -r1.264 decl2.c
*** decl2.c	1999/09/23 02:04:33	1.264
--- decl2.c	1999/09/24 00:59:31
*************** finish_anon_union (anon_union_decl)
*** 2126,2132 ****
       tree anon_union_decl;
  {
    tree type = TREE_TYPE (anon_union_decl);
-   tree elems = NULL_TREE;
    tree main_decl;
    int public_p = TREE_PUBLIC (anon_union_decl);
    int static_p = TREE_STATIC (anon_union_decl);
--- 2126,2131 ----
*************** finish_anon_union (anon_union_decl)
*** 2141,2147 ****
        return;
      }
  
!   main_decl = build_anon_union_vars (anon_union_decl, &elems, 
  				     static_p, external_p);
  
    if (main_decl == NULL_TREE)
--- 2140,2147 ----
        return;
      }
  
!   main_decl = build_anon_union_vars (anon_union_decl,
! 				     &DECL_ANON_UNION_ELEMS (anon_union_decl),
  				     static_p, external_p);
  
    if (main_decl == NULL_TREE)
*************** finish_anon_union (anon_union_decl)
*** 2154,2164 ****
      {
        make_decl_rtl (main_decl, 0, toplevel_bindings_p ());
        DECL_RTL (anon_union_decl) = DECL_RTL (main_decl);
      }
! 
!   /* The following call assumes that there are never any cleanups
!      for anonymous unions--a reasonable assumption.  */
!   expand_anon_union_decl (anon_union_decl, NULL_TREE, elems);
  }
  
  /* Finish processing a builtin type TYPE.  It's name is NAME,
--- 2154,2165 ----
      {
        make_decl_rtl (main_decl, 0, toplevel_bindings_p ());
        DECL_RTL (anon_union_decl) = DECL_RTL (main_decl);
+       expand_anon_union_decl (anon_union_decl, 
+ 			      NULL_TREE,
+ 			      DECL_ANON_UNION_ELEMS (anon_union_decl));
      }
!   else
!     add_decl_stmt (anon_union_decl);
  }
  
  /* Finish processing a builtin type TYPE.  It's name is NAME,
Index: cp/semantics.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/semantics.c,v
retrieving revision 1.88
diff -c -p -r1.88 semantics.c
*** semantics.c	1999/09/21 07:45:38	1.88
--- semantics.c	1999/09/24 00:59:35
*************** expand_stmt (t)
*** 2254,2261 ****
  	    if (TREE_CODE (decl) == VAR_DECL 
  		&& !TREE_STATIC (decl)
  		&& !DECL_EXTERNAL (decl))
! 	      /* Let the back-end know about this variable.  */
! 	      emit_local_var (decl);
  
  	    resume_momentary (i);
  	  }
--- 2254,2267 ----
  	    if (TREE_CODE (decl) == VAR_DECL 
  		&& !TREE_STATIC (decl)
  		&& !DECL_EXTERNAL (decl))
! 	      {
! 		/* Let the back-end know about this variable.  */
! 		if (!ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
! 		  emit_local_var (decl);
! 		else
! 		  expand_anon_union_decl (decl, NULL_TREE, 
! 					  DECL_ANON_UNION_ELEMS (decl));
! 	      }
  
  	    resume_momentary (i);
  	  }
Index: cp/typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.215
diff -c -p -r1.215 typeck.c
*** typeck.c	1999/09/21 19:49:04	1.215
--- typeck.c	1999/09/24 00:59:40
*************** mark_addressable (exp)
*** 4999,5006 ****
  	    && !DECL_ARTIFICIAL (x) && extra_warnings)
  	  cp_warning ("address requested for `%D', which is declared `register'",
  		      x);
- 	put_var_into_stack (x);
  	TREE_ADDRESSABLE (x) = 1;
  	return 1;
  
        case FUNCTION_DECL:
--- 4999,5008 ----
  	    && !DECL_ARTIFICIAL (x) && extra_warnings)
  	  cp_warning ("address requested for `%D', which is declared `register'",
  		      x);
  	TREE_ADDRESSABLE (x) = 1;
+ 	TREE_USED (x) = 1;
+ 	if (current_function && expanding_p)
+ 	  put_var_into_stack (x);
  	return 1;
  
        case FUNCTION_DECL:



More information about the Gcc-bugs mailing list