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]

C++ PATCH: Fix PR 10503, PR 10506


This patch stomps a couple more regressions...

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com

2003-04-27  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/10506
	* method.c (use_thunk): Decrement immediate_size_expand.

	PR c++/10503
	* cp-tree.h (DECL_VAR_MARKED_P): New macro.
	(DECL_MAYBE_TEMPLATE): Remove.
	* class.c (fixed_type_or_null): Avoid infinite recursion.

2003-04-27  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/10506
	* g++.dg/init/new6.C: New test.

	PR c++/10503
	* g++.dg/init/ref6.C: New test.

Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.533
diff -c -5 -p -r1.533 class.c
*** cp/class.c	23 Apr 2003 16:27:24 -0000	1.533
--- cp/class.c	28 Apr 2003 06:00:04 -0000
*************** fixed_type_or_null (tree instance, int* 
*** 5386,5400 ****
        else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE)
          {
            /* Reference variables should be references to objects.  */
            if (nonnull)
  	    *nonnull = 1;
! 
! 	  if (TREE_CODE (instance) == VAR_DECL
! 	      && DECL_INITIAL (instance))
! 	    return fixed_type_or_null (DECL_INITIAL (instance),
! 				       nonnull, cdtorp);
  	}
        return NULL_TREE;
  
      default:
        return NULL_TREE;
--- 5386,5410 ----
        else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE)
          {
            /* Reference variables should be references to objects.  */
            if (nonnull)
  	    *nonnull = 1;
! 	  
! 	  /* DECL_VAR_MARKED_P is used to prevent recursion; a
! 	     variable's initializer may refer to the variable
! 	     itself.  */
! 	  if (TREE_CODE (instance) == VAR_DECL 
! 	      && DECL_INITIAL (instance)
! 	      && !DECL_VAR_MARKED_P (instance))
! 	    {
! 	      tree type;
! 	      DECL_VAR_MARKED_P (instance) = 1;
! 	      type = fixed_type_or_null (DECL_INITIAL (instance),
! 					 nonnull, cdtorp);
! 	      DECL_VAR_MARKED_P (instance) = 0;
! 	      return type;
! 	    }
  	}
        return NULL_TREE;
  
      default:
        return NULL_TREE;
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.839
diff -c -5 -p -r1.839 cp-tree.h
*** cp/cp-tree.h	23 Apr 2003 16:27:25 -0000	1.839
--- cp/cp-tree.h	28 Apr 2003 06:00:05 -0000
*************** struct diagnostic_context;
*** 93,103 ****
        DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL)
     2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL).
        DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL)
     3: DECL_IN_AGGR_P.
     4: DECL_C_BIT_FIELD (in a FIELD_DECL)
!       DECL_MAYBE_TEMPLATE (in a FUNCTION_DECL)
     5: DECL_INTERFACE_KNOWN.
     6: DECL_THIS_STATIC (in VAR_DECL or FUNCTION_DECL).
     7: DECL_DEAD_FOR_LOCAL (in VAR_DECL).
        DECL_THUNK_P (in a member FUNCTION_DECL)
  
--- 93,103 ----
        DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL)
     2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL).
        DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL)
     3: DECL_IN_AGGR_P.
     4: DECL_C_BIT_FIELD (in a FIELD_DECL)
!       DECL_VAR_MARKED_P (in a VAR_DECL)
     5: DECL_INTERFACE_KNOWN.
     6: DECL_THIS_STATIC (in VAR_DECL or FUNCTION_DECL).
     7: DECL_DEAD_FOR_LOCAL (in VAR_DECL).
        DECL_THUNK_P (in a member FUNCTION_DECL)
  
*************** struct lang_decl GTY(())
*** 2129,2138 ****
--- 2129,2144 ----
     template-specific information.  */
  #define DECL_TEMPLATE_INFO(NODE) \
    (DECL_LANG_SPECIFIC (VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK (NODE)) \
     ->decl_flags.u.template_info)
  
+ /* For a VAR_DECL, indicates that the variable has been processed.
+    This flag is set and unset throughout the code; it is always
+    used for a temporary purpose.  */
+ #define DECL_VAR_MARKED_P(NODE) \
+   (DECL_LANG_FLAG_4 (VAR_DECL_CHECK (NODE)))
+ 
  /* Template information for a RECORD_TYPE or UNION_TYPE.  */
  #define CLASSTYPE_TEMPLATE_INFO(NODE) \
    (LANG_TYPE_CLASS_CHECK (RECORD_OR_UNION_TYPE_CHECK (NODE))->template_info)
  
  /* Template information for an ENUMERAL_TYPE.  Although an enumeration may
*************** struct lang_decl GTY(())
*** 2804,2816 ****
  /* Nonzero iff we are currently processing a declaration for an
     entity with its own template parameter list, and which is not a
     full specialization.  */
  #define PROCESSING_REAL_TEMPLATE_DECL_P() \
    (processing_template_decl > template_class_depth (current_class_type))
- 
- /* This function may be a guiding decl for a template.  */
- #define DECL_MAYBE_TEMPLATE(NODE) DECL_LANG_FLAG_4 (NODE)
  
  /* Nonzero if this VAR_DECL or FUNCTION_DECL has already been
     instantiated, i.e. its definition has been generated from the
     pattern given in the the template.  */
  #define DECL_TEMPLATE_INSTANTIATED(NODE) \
--- 2810,2819 ----
Index: cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.246
diff -c -5 -p -r1.246 method.c
*** cp/method.c	3 Apr 2003 15:42:16 -0000	1.246
--- cp/method.c	28 Apr 2003 06:00:06 -0000
*************** use_thunk (tree thunk_fndecl, bool emit_
*** 437,446 ****
--- 437,449 ----
  				       fixed_offset, virtual_value, function);
  
        assemble_end_function (thunk_fndecl, fnname);
        current_function_decl = 0;
        cfun = 0;
+       /* Because init_function_start increments this, we must
+ 	 decrement it.  */
+       immediate_size_expand--;
        TREE_ASM_WRITTEN (thunk_fndecl) = 1;
      }
    else
      {
        /* If this is a covariant thunk, or we don't have the necessary
Index: testsuite/g++.dg/init/new6.C
===================================================================
RCS file: testsuite/g++.dg/init/new6.C
diff -N testsuite/g++.dg/init/new6.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/new6.C	28 Apr 2003 06:00:13 -0000
***************
*** 0 ****
--- 1,8 ----
+ // { dg-options "-fkeep-inline-functions" }
+ 
+ struct B1 { virtual ~B1(); };
+ struct B2 { virtual ~B2(); };
+ struct D : B1, B2 {};
+ struct X : D      { X (); };
+ 
+ X::X () { new int; }
Index: testsuite/g++.dg/init/ref6.C
===================================================================
RCS file: testsuite/g++.dg/init/ref6.C
diff -N testsuite/g++.dg/init/ref6.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/ref6.C	28 Apr 2003 06:00:13 -0000
***************
*** 0 ****
--- 1,12 ----
+ struct B {
+   void g() { }
+ };
+ 
+ struct A {
+   void f() {
+     B &b = b;
+     b.g();
+   }
+ };
+ 
+ int main(void) { }


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