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]

(C++) tidying patch


This patch fixes various --enable-checking problems in the Perennial
testsuite, one typo that was an actual bug, and various free software
packages that (inappropriately) try to delete [] void*.

New test: g++.ext/delvoid.C.

2000-06-22  Jason Merrill  <jason@redhat.com>

	* decl.c (grok_op_properties): Fix typo.

	* pt.c (check_explicit_specialization): Clarify error.

	* decl2.c (delete_sanity): Clarify warning, avoid failure on
	deleting void*.

	* decl.c (pushdecl): Also pull out one of the FUNCTION_DECLs from
	an old OVERLOAD when we're declaring a non-function.
	(pushdecl, destroy_local_var): Check for error_mark_node.
	(warn_extern_redeclared_static): Also bail early if 
	we're a CONST_DECL.
	(push_overloaded_decl): Ignore an old error_mark_node.

*** decl.c.~1~	Thu Jun 22 16:35:01 2000
--- decl.c	Thu Jun 22 16:35:06 2000
*************** warn_extern_redeclared_static (newdecl, 
*** 3092,3098 ****
    tree name;
  
    if (TREE_CODE (newdecl) == TYPE_DECL
!       || TREE_CODE (newdecl) == TEMPLATE_DECL)
      return;
  
    /* Don't get confused by static member functions; that's a different
--- 3092,3099 ----
    tree name;
  
    if (TREE_CODE (newdecl) == TYPE_DECL
!       || TREE_CODE (newdecl) == TEMPLATE_DECL
!       || TREE_CODE (newdecl) == CONST_DECL)
      return;
  
    /* Don't get confused by static member functions; that's a different
*************** pushdecl (x)
*** 3863,3876 ****
  	 actually the same as the function we are declaring.  (If
  	 there is one, we have to merge our declaration with the
  	 previous declaration.)  */
!       if (t && TREE_CODE (t) == OVERLOAD && TREE_CODE (x) == FUNCTION_DECL)
  	{
  	  tree match;
  
! 	  for (match = t; match; match = OVL_NEXT (match))
! 	    if (DECL_ASSEMBLER_NAME (OVL_CURRENT (t))
! 		== DECL_ASSEMBLER_NAME (x))
! 	      break;
  
  	  if (match)
  	    t = OVL_CURRENT (match);
--- 3864,3883 ----
  	 actually the same as the function we are declaring.  (If
  	 there is one, we have to merge our declaration with the
  	 previous declaration.)  */
!       if (t && TREE_CODE (t) == OVERLOAD)
  	{
  	  tree match;
  
! 	  if (TREE_CODE (x) == FUNCTION_DECL)
! 	    for (match = t; match; match = OVL_NEXT (match))
! 	      {
! 		if (DECL_ASSEMBLER_NAME (OVL_CURRENT (t))
! 		    == DECL_ASSEMBLER_NAME (x))
! 		  break;
! 	      }
! 	  else
! 	    /* Just choose one.  */
! 	    match = t;
  
  	  if (match)
  	    t = OVL_CURRENT (match);
*************** pushdecl (x)
*** 4010,4015 ****
--- 4017,4023 ----
  	  tree decl;
  
  	  if (IDENTIFIER_NAMESPACE_VALUE (name) != NULL_TREE
+ 	      && IDENTIFIER_NAMESPACE_VALUE (name) != error_mark_node
  	      && (DECL_EXTERNAL (IDENTIFIER_NAMESPACE_VALUE (name))
  		  || TREE_PUBLIC (IDENTIFIER_NAMESPACE_VALUE (name))))
  	    decl = IDENTIFIER_NAMESPACE_VALUE (name);
*************** push_overloaded_decl (decl, flags)
*** 4577,4582 ****
--- 4585,4593 ----
  		return fn;
  	    }
  	}
+       else if (old == error_mark_node)
+ 	/* Ignore the undefined symbol marker.  */
+ 	old = NULL_TREE;
        else
  	{
  	  cp_error_at ("previous non-function declaration `%#D'", old);
*************** destroy_local_var (decl)
*** 8022,8028 ****
      return;
  
    /* And only things with destructors need cleaning up.  */
!   if (TYPE_HAS_TRIVIAL_DESTRUCTOR (type))
      return;
  
    if (TREE_CODE (decl) == VAR_DECL &&
--- 8033,8040 ----
      return;
  
    /* And only things with destructors need cleaning up.  */
!   if (type == error_mark_node
!       || TYPE_HAS_TRIVIAL_DESTRUCTOR (type))
      return;
  
    if (TREE_CODE (decl) == VAR_DECL &&
*************** grok_op_properties (decl, virtualp, frie
*** 12583,12589 ****
  		  break;
  
  		case PREDECREMENT_EXPR:
! 		  operator_code = PREDECREMENT_EXPR;
  		  break;
  
  		default:
--- 12595,12601 ----
  		  break;
  
  		case PREDECREMENT_EXPR:
! 		  operator_code = POSTDECREMENT_EXPR;
  		  break;
  
  		default:
*** decl2.c.~1~	Thu Jun 22 16:35:01 2000
--- decl2.c	Thu Jun 22 16:35:06 2000
*************** delete_sanity (exp, size, doing_vec, use
*** 1283,1290 ****
  
    /* Deleting ptr to void is undefined behaviour [expr.delete/3].  */
    if (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE)
!     cp_warning ("`%T' is not a pointer-to-object type", type);
!   
    /* An array can't have been allocated by new, so complain.  */
    if (TREE_CODE (t) == ADDR_EXPR
        && TREE_CODE (TREE_OPERAND (t, 0)) == VAR_DECL
--- 1283,1293 ----
  
    /* Deleting ptr to void is undefined behaviour [expr.delete/3].  */
    if (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE)
!     {
!       cp_warning ("deleting `%T' is undefined", type);
!       doing_vec = 0;
!     }
! 
    /* An array can't have been allocated by new, so complain.  */
    if (TREE_CODE (t) == ADDR_EXPR
        && TREE_CODE (TREE_OPERAND (t, 0)) == VAR_DECL
*** pt.c.~1~	Thu Jun 22 16:35:01 2000
--- pt.c	Thu Jun 22 16:35:06 2000
*************** check_explicit_specialization (declarato
*** 1300,1307 ****
  	  /* This case handles bogus declarations like template <>
  	     template <class T> void f<int>(); */
  
! 	  cp_error ("template-id `%D' in declaration of primary template",
! 		    declarator);
  	  return decl;
  	}
  
--- 1300,1311 ----
  	  /* This case handles bogus declarations like template <>
  	     template <class T> void f<int>(); */
  
! 	  if (uses_template_parms (declarator))
! 	    cp_error ("partial specialization `%D' of function template",
! 		      declarator);
! 	  else
! 	    cp_error ("template-id `%D' in declaration of primary template",
! 		      declarator);
  	  return decl;
  	}
  

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