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: PR 15083, 15640, 15471


This patch fixes several more C++ regressions; all the patches are
straightforward.

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

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-05-28  Mark Mitchell  <mark@codesourcery.com>

	PR c++/15083
	* decl2.c (delete_sanity): Set TREE_SIDE_EFFECTS on a DELETE_EXPR,
	even in a templat.e
	* init.c (build_new): Likewise.

	PR c++/15640
	* name-lookup.c (arg_assoc): Robustify.

	PR c++/15471
	* typeck.c (unary_complex_lvalue): Use context_for_name_lookup
	when determining the scope to use for a pointer to member.

2004-05-28  Mark Mitchell  <mark@codesourcery.com>

	PR c++/15083
	* g++.dg/warn/noeffect5.C: New test.

	PR c++/15471
	* g++.dg/expr/ptrmem4.C: New test.

	PR c++/15640
	* g++.dg/template/operator3.C: New test.

Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.695.4.7
diff -c -5 -p -r1.695.4.7 decl2.c
*** cp/decl2.c	8 Apr 2004 13:37:10 -0000	1.695.4.7
--- cp/decl2.c	28 May 2004 22:25:35 -0000
*************** delete_sanity (tree exp, tree size, bool
*** 447,456 ****
--- 447,457 ----
    if (processing_template_decl)
      {
        t = build_min (DELETE_EXPR, void_type_node, exp, size);
        DELETE_EXPR_USE_GLOBAL (t) = use_global_delete;
        DELETE_EXPR_USE_VEC (t) = doing_vec;
+       TREE_SIDE_EFFECTS (t) = 1;
        return t;
      }
  
    exp = convert_from_reference (exp);
  
Index: cp/init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v
retrieving revision 1.356.2.9
diff -c -5 -p -r1.356.2.9 init.c
*** cp/init.c	10 Mar 2004 21:04:13 -0000	1.356.2.9
--- cp/init.c	28 May 2004 22:25:35 -0000
*************** build_new (tree placement, tree decl, tr
*** 1795,1804 ****
--- 1795,1805 ----
  	t = type;
  	
        rval = build_min (NEW_EXPR, build_pointer_type (type), 
  			placement, t, init);
        NEW_EXPR_USE_GLOBAL (rval) = use_global_new;
+       TREE_SIDE_EFFECTS (rval) = 1;
        return rval;
      }
  
    /* ``A reference cannot be created by the new operator.  A reference
       is not an object (8.2.2, 8.4.3), so a pointer to it could not be
Index: cp/name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.34.2.12
diff -c -5 -p -r1.34.2.12 name-lookup.c
*** cp/name-lookup.c	23 May 2004 17:52:16 -0000	1.34.2.12
--- cp/name-lookup.c	28 May 2004 22:25:36 -0000
*************** arg_assoc (struct arg_lookup *k, tree n)
*** 4444,4457 ****
        /* Now the arguments.  */
        for (ix = TREE_VEC_LENGTH (args); ix--;)
  	if (arg_assoc_template_arg (k, TREE_VEC_ELT (args, ix)) == 1)
  	  return true;
      }
!   else
      {
-       my_friendly_assert (TREE_CODE (n) == OVERLOAD, 980715);
-       
        for (; n; n = OVL_CHAIN (n))
  	if (arg_assoc_type (k, TREE_TYPE (OVL_FUNCTION (n))))
  	  return true;
      }
  
--- 4444,4455 ----
        /* Now the arguments.  */
        for (ix = TREE_VEC_LENGTH (args); ix--;)
  	if (arg_assoc_template_arg (k, TREE_VEC_ELT (args, ix)) == 1)
  	  return true;
      }
!   else if (TREE_CODE (n) == OVERLOAD)
      {
        for (; n; n = OVL_CHAIN (n))
  	if (arg_assoc_type (k, TREE_TYPE (OVL_FUNCTION (n))))
  	  return true;
      }
  
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.519.2.16
diff -c -5 -p -r1.519.2.16 typeck.c
*** cp/typeck.c	24 May 2004 02:22:16 -0000	1.519.2.16
--- cp/typeck.c	28 May 2004 22:25:36 -0000
*************** unary_complex_lvalue (enum tree_code cod
*** 4224,4234 ****
  	    {
  	      error ("cannot create pointer to reference member `%D'", t);
  	      return error_mark_node;
  	    }
  
! 	  type = build_ptrmem_type (DECL_FIELD_CONTEXT (t), TREE_TYPE (t));
  	  t = make_ptrmem_cst (type, TREE_OPERAND (arg, 1));
  	  return t;
  	}
      }
  
--- 4224,4235 ----
  	    {
  	      error ("cannot create pointer to reference member `%D'", t);
  	      return error_mark_node;
  	    }
  
! 	  type = build_ptrmem_type (context_for_name_lookup (t), 
! 				    TREE_TYPE (t));
  	  t = make_ptrmem_cst (type, TREE_OPERAND (arg, 1));
  	  return t;
  	}
      }
  
Index: testsuite/g++.dg/expr/ptrmem4.C
===================================================================
RCS file: testsuite/g++.dg/expr/ptrmem4.C
diff -N testsuite/g++.dg/expr/ptrmem4.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/expr/ptrmem4.C	28 May 2004 22:25:37 -0000
***************
*** 0 ****
--- 1,16 ----
+ // PR c++/15471
+ // { dg-do run }
+ 
+ struct myclass { 
+   unsigned a; 
+   union { 
+     unsigned x; 
+   }; 
+ }; 
+  
+ int main () {
+   myclass foo;
+   unsigned myclass::* member = &myclass::x; 
+   if (&(foo.*member) != &foo.x)
+     return 1;
+ }
Index: testsuite/g++.dg/template/operator3.C
===================================================================
RCS file: testsuite/g++.dg/template/operator3.C
diff -N testsuite/g++.dg/template/operator3.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/operator3.C	28 May 2004 22:25:37 -0000
***************
*** 0 ****
--- 1,10 ----
+ // PR c++/15640
+ 
+ struct A {
+   void foo(void);
+ };
+ 
+ template <int> void bar() {
+   A a;
+   a + a.foo; // { dg-error "" }
+ }
Index: testsuite/g++.dg/warn/noeffect5.C
===================================================================
RCS file: testsuite/g++.dg/warn/noeffect5.C
diff -N testsuite/g++.dg/warn/noeffect5.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/noeffect5.C	28 May 2004 22:25:37 -0000
***************
*** 0 ****
--- 1,14 ----
+ // { dg-options "-Wall" }
+ // PR c++/15083
+ 
+ extern "C" int printf(const char*,...);
+ struct Counter {
+   Counter(){printf("Hello World.\n");}
+ };
+ template< typename T >
+ void resetData() {
+   new Counter();
+ }
+ int main() {
+   resetData<int>();
+ } 


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