diff mbox series

[C++] Improve delete expressions locations

Message ID 31eca960-7ad2-1c34-18f5-96f40fbe9b8c@oracle.com
State New
Headers show
Series [C++] Improve delete expressions locations | expand

Commit Message

Paolo Carlini Dec. 20, 2019, 4:35 p.m. UTC
Hi,

more of the last idea, this time applied to cp_parser_delete_expression 
/ delete_sanity (thus build_delete and build_vec_delete which provide 
tests). Nothing particularly remarkable in this case. Tested x86_64-linux.

Thanks, Paolo.

///////////////////////////////
/gcc/cp
2019-12-20  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl2.c (delete_sanity): Add location_t parameter and use
	it throughout.
	* init.c (build_vec_delete_1): Likewise.
	(build_delete): Likewise.
	(build_vec_delete): Likewise.
	(perform_target_ctor): Adjust call.
	(perform_member_init): Likewise.
	(build_vec_init): Likewise.
	* decl.c (cxx_maybe_build_cleanup): Likewise.
	* pt.c (tsubst_copy_and_build): Likewise.
	* parser.c (cp_parser_delete_expression): Likewise, pass the
	combined_loc.
	* cp-tree.h: Update declarations.

/libcc1
2019-12-20  Paolo Carlini  <paolo.carlini@oracle.com>

	* libcp1plugin.cc (plugin_build_unary_expr): Update delete_sanity
	call.

/gcc/testsuite
2019-12-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/init/delete1.C: Check locations too.
	* g++.dg/ipa/pr85607.C: Likewise.
	* g++.dg/warn/Wdelete-incomplete-1.C: Likewise.
	* g++.dg/warn/delete-non-virtual-dtor.C: Likewise.
	* g++.dg/warn/incomplete1.C: Likewise.

Comments

Jason Merrill Dec. 26, 2019, 3:49 a.m. UTC | #1
On 12/20/19 11:35 AM, Paolo Carlini wrote:
> Hi,
> 
> more of the last idea, this time applied to cp_parser_delete_expression 
> / delete_sanity (thus build_delete and build_vec_delete which provide 
> tests). Nothing particularly remarkable in this case. Tested x86_64-linux.
> 
> Thanks, Paolo.
> 
> ///////////////////////////////
> 
OK.
diff mbox series

Patch

Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 279563)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -6583,7 +6583,8 @@  extern bool vague_linkage_p			(tree);
 extern void grokclassfn				(tree, tree,
 						 enum overload_flags);
 extern tree grok_array_decl			(location_t, tree, tree, bool);
-extern tree delete_sanity			(tree, tree, bool, int, tsubst_flags_t);
+extern tree delete_sanity			(location_t, tree, tree, bool,
+						 int, tsubst_flags_t);
 extern tree check_classfn			(tree, tree, tree);
 extern void check_member_template		(tree);
 extern tree grokfield (const cp_declarator *, cp_decl_specifier_seq *,
@@ -6725,11 +6726,11 @@  extern tree build_new				(vec<tree, va_gc> **, tre
 extern tree get_temp_regvar			(tree, tree);
 extern tree build_vec_init			(tree, tree, tree, bool, int,
                                                  tsubst_flags_t);
-extern tree build_delete			(tree, tree,
+extern tree build_delete			(location_t, tree, tree,
 						 special_function_kind,
 						 int, int, tsubst_flags_t);
 extern void push_base_cleanups			(void);
-extern tree build_vec_delete			(tree, tree,
+extern tree build_vec_delete			(location_t, tree, tree,
 						 special_function_kind, int,
 						 tsubst_flags_t);
 extern tree create_temporary_var		(tree);
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 279563)
+++ gcc/cp/decl.c	(working copy)
@@ -17311,7 +17311,7 @@  cxx_maybe_build_cleanup (tree decl, tsubst_flags_t
       else
 	addr = build_address (decl);
 
-      call = build_delete (TREE_TYPE (addr), addr,
+      call = build_delete (input_location, TREE_TYPE (addr), addr,
 			   sfk_complete_destructor, flags, 0, complain);
       if (call == error_mark_node)
 	cleanup = error_mark_node;
Index: gcc/cp/decl2.c
===================================================================
--- gcc/cp/decl2.c	(revision 279563)
+++ gcc/cp/decl2.c	(working copy)
@@ -475,8 +475,8 @@  grok_array_decl (location_t loc, tree array_expr,
    Implements ARM $5.3.4.  This is called from the parser.  */
 
 tree
-delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete,
-	       tsubst_flags_t complain)
+delete_sanity (location_t loc, tree exp, tree size, bool doing_vec,
+	       int use_global_delete, tsubst_flags_t complain)
 {
   tree t, type;
 
@@ -489,14 +489,16 @@  tree
       DELETE_EXPR_USE_GLOBAL (t) = use_global_delete;
       DELETE_EXPR_USE_VEC (t) = doing_vec;
       TREE_SIDE_EFFECTS (t) = 1;
+      SET_EXPR_LOCATION (t, loc);
       return t;
     }
 
+  location_t exp_loc = cp_expr_loc_or_loc (exp, loc);
+
   /* An array can't have been allocated by new, so complain.  */
   if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
       && (complain & tf_warning))
-    warning_at (cp_expr_loc_or_input_loc (exp), 0,
-		"deleting array %q#E", exp);
+    warning_at (exp_loc, 0, "deleting array %q#E", exp);
 
   t = build_expr_type_conversion (WANT_POINTER, exp, true);
 
@@ -503,7 +505,7 @@  tree
   if (t == NULL_TREE || t == error_mark_node)
     {
       if (complain & tf_error)
-	error_at (cp_expr_loc_or_input_loc (exp),
+	error_at (exp_loc,
 		  "type %q#T argument given to %<delete%>, expected pointer",
 		  TREE_TYPE (exp));
       return error_mark_node;
@@ -517,7 +519,7 @@  tree
   if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
     {
       if (complain & tf_error)
-	error_at (cp_expr_loc_or_input_loc (exp),
+	error_at (exp_loc,
 		  "cannot delete a function.  Only pointer-to-objects are "
 		  "valid arguments to %<delete%>");
       return error_mark_node;
@@ -527,7 +529,7 @@  tree
   if (VOID_TYPE_P (TREE_TYPE (type)))
     {
       if (complain & tf_warning)
-	warning_at (cp_expr_loc_or_input_loc (exp), OPT_Wdelete_incomplete,
+	warning_at (exp_loc, OPT_Wdelete_incomplete,
 		    "deleting %qT is undefined", type);
       doing_vec = 0;
     }
@@ -534,14 +536,14 @@  tree
 
   /* Deleting a pointer with the value zero is valid and has no effect.  */
   if (integer_zerop (t))
-    return build1 (NOP_EXPR, void_type_node, t);
+    return build1_loc (loc, NOP_EXPR, void_type_node, t);
 
   if (doing_vec)
-    return build_vec_delete (t, /*maxindex=*/NULL_TREE,
+    return build_vec_delete (loc, t, /*maxindex=*/NULL_TREE,
 			     sfk_deleting_destructor,
 			     use_global_delete, complain);
   else
-    return build_delete (type, t, sfk_deleting_destructor,
+    return build_delete (loc, type, t, sfk_deleting_destructor,
 			 LOOKUP_NORMAL, use_global_delete,
 			 complain);
 }
Index: gcc/cp/init.c
===================================================================
--- gcc/cp/init.c	(revision 279563)
+++ gcc/cp/init.c	(working copy)
@@ -535,7 +535,8 @@  perform_target_ctor (tree init)
 				     tf_warning_or_error));
   if (type_build_dtor_call (type))
     {
-      tree expr = build_delete (type, decl, sfk_complete_destructor,
+      tree expr = build_delete (input_location,
+				type, decl, sfk_complete_destructor,
 				LOOKUP_NORMAL
 				|LOOKUP_NONVIRTUAL
 				|LOOKUP_DESTRUCTOR,
@@ -980,7 +981,8 @@  perform_member_init (tree member, tree init)
 					     /*access_path=*/NULL_TREE,
 					     /*preserve_reference=*/false,
 					     tf_warning_or_error);
-      expr = build_delete (type, expr, sfk_complete_destructor,
+      expr = build_delete (input_location,
+			   type, expr, sfk_complete_destructor,
 			   LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0,
 			   tf_warning_or_error);
 
@@ -3924,7 +3926,7 @@  build_new (vec<tree, va_gc> **placement, tree type
 }
 
 static tree
-build_vec_delete_1 (tree base, tree maxindex, tree type,
+build_vec_delete_1 (location_t loc, tree base, tree maxindex, tree type,
 		    special_function_kind auto_delete_vec,
 		    int use_global_delete, tsubst_flags_t complain)
 {
@@ -3958,7 +3960,7 @@  static tree
   if (base == error_mark_node || maxindex == error_mark_node)
     return error_mark_node;
 
-  if (!verify_type_context (input_location, TCTX_DEALLOCATION, type,
+  if (!verify_type_context (loc, TCTX_DEALLOCATION, type,
 			    !(complain & tf_error)))
     return error_mark_node;
 
@@ -3967,14 +3969,14 @@  static tree
       if (complain & tf_warning)
 	{
 	  auto_diagnostic_group d;
-	  if (warning (OPT_Wdelete_incomplete,
-			 "possible problem detected in invocation of "
-			 "operator %<delete []%>"))
+	  if (warning_at (loc, OPT_Wdelete_incomplete,
+			  "possible problem detected in invocation of "
+			  "operator %<delete []%>"))
 	    {
 	      cxx_incomplete_type_diagnostic (base, type, DK_WARNING);
-	      inform (input_location, "neither the destructor nor the "
-			"class-specific operator %<delete []%> will be called, "
-			"even if they are declared when the class is defined");
+	      inform (loc, "neither the destructor nor the "
+		      "class-specific operator %<delete []%> will be called, "
+		      "even if they are declared when the class is defined");
 	    }
 	}
       /* This size won't actually be used.  */
@@ -3991,7 +3993,7 @@  static tree
       /* Make sure the destructor is callable.  */
       if (type_build_dtor_call (type))
 	{
-	  tmp = build_delete (ptype, base, sfk_complete_destructor,
+	  tmp = build_delete (loc, ptype, base, sfk_complete_destructor,
 			      LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 1,
 			      complain);
 	  if (tmp == error_mark_node)
@@ -4006,9 +4008,9 @@  static tree
 
   tbase = create_temporary_var (ptype);
   DECL_INITIAL (tbase)
-    = fold_build_pointer_plus_loc (input_location, fold_convert (ptype, base),
+    = fold_build_pointer_plus_loc (loc, fold_convert (ptype, base),
 				   virtual_size);
-  tbase_init = build_stmt (input_location, DECL_EXPR, tbase);
+  tbase_init = build_stmt (loc, DECL_EXPR, tbase);
   controller = build3 (BIND_EXPR, void_type_node, tbase, NULL_TREE, NULL_TREE);
   TREE_SIDE_EFFECTS (controller) = 1;
 
@@ -4015,21 +4017,21 @@  static tree
   body = build1 (EXIT_EXPR, void_type_node,
 		 build2 (EQ_EXPR, boolean_type_node, tbase,
 			 fold_convert (ptype, base)));
-  tmp = fold_build1_loc (input_location, NEGATE_EXPR, sizetype, size_exp);
+  tmp = fold_build1_loc (loc, NEGATE_EXPR, sizetype, size_exp);
   tmp = fold_build_pointer_plus (tbase, tmp);
-  tmp = cp_build_modify_expr (input_location, tbase, NOP_EXPR, tmp, complain);
+  tmp = cp_build_modify_expr (loc, tbase, NOP_EXPR, tmp, complain);
   if (tmp == error_mark_node)
     return error_mark_node;
-  body = build_compound_expr (input_location, body, tmp);
-  tmp = build_delete (ptype, tbase, sfk_complete_destructor,
+  body = build_compound_expr (loc, body, tmp);
+  tmp = build_delete (loc, ptype, tbase, sfk_complete_destructor,
 		      LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 1,
 		      complain);
   if (tmp == error_mark_node)
     return error_mark_node;
-  body = build_compound_expr (input_location, body, tmp);
+  body = build_compound_expr (loc, body, tmp);
 
   loop = build1 (LOOP_EXPR, void_type_node, body);
-  loop = build_compound_expr (input_location, tbase_init, loop);
+  loop = build_compound_expr (loc, tbase_init, loop);
 
  no_destructor:
   /* Delete the storage if appropriate.  */
@@ -4049,7 +4051,7 @@  static tree
 	  tree cookie_size;
 
 	  cookie_size = targetm.cxx.get_cookie_size (type);
-	  base_tbd = cp_build_binary_op (input_location,
+	  base_tbd = cp_build_binary_op (loc,
 					 MINUS_EXPR,
 					 cp_convert (string_type_node,
 						     base, complain),
@@ -4088,12 +4090,12 @@  static tree
     body = integer_zero_node;
 
   /* Outermost wrapper: If pointer is null, punt.  */
-  tree cond = build2_loc (input_location, NE_EXPR, boolean_type_node, base,
+  tree cond = build2_loc (loc, NE_EXPR, boolean_type_node, base,
 			  fold_convert (TREE_TYPE (base), nullptr_node));
   /* This is a compiler generated comparison, don't emit
      e.g. -Wnonnull-compare warning for it.  */
   TREE_NO_WARNING (cond) = 1;
-  body = build3_loc (input_location, COND_EXPR, void_type_node,
+  body = build3_loc (loc, COND_EXPR, void_type_node,
 		     cond, body, integer_zero_node);
   COND_EXPR_IS_VEC_DELETE (body) = true;
   body = build1 (NOP_EXPR, void_type_node, body);
@@ -4714,7 +4716,7 @@  build_vec_init (tree base, tree maxindex, tree ini
 				complain);
 
       finish_cleanup_try_block (try_block);
-      e = build_vec_delete_1 (rval, m,
+      e = build_vec_delete_1 (input_location, rval, m,
 			      inner_elt_type, sfk_complete_destructor,
 			      /*use_global_delete=*/0, complain);
       if (e == error_mark_node)
@@ -4801,7 +4803,8 @@  build_dtor_call (tree exp, special_function_kind d
    flags.  See cp-tree.h for more info.  */
 
 tree
-build_delete (tree otype, tree addr, special_function_kind auto_delete,
+build_delete (location_t loc, tree otype, tree addr,
+	      special_function_kind auto_delete,
 	      int flags, int use_global_delete, tsubst_flags_t complain)
 {
   tree expr;
@@ -4824,10 +4827,10 @@  tree
       if (TYPE_DOMAIN (type) == NULL_TREE)
 	{
 	  if (complain & tf_error)
-	    error ("unknown array size in delete");
+	    error_at (loc, "unknown array size in delete");
 	  return error_mark_node;
 	}
-      return build_vec_delete (addr, array_type_nelts (type),
+      return build_vec_delete (loc, addr, array_type_nelts (type),
 			       auto_delete, use_global_delete, complain);
     }
 
@@ -4848,7 +4851,7 @@  tree
 	{
 	  complete_type (type);
 	  if (deleting
-	      && !verify_type_context (input_location, TCTX_DEALLOCATION, type,
+	      && !verify_type_context (loc, TCTX_DEALLOCATION, type,
 				       !(complain & tf_error)))
 	    return error_mark_node;
 
@@ -4857,12 +4860,12 @@  tree
 	      if (complain & tf_warning)
 		{
 		  auto_diagnostic_group d;
-		  if (warning (OPT_Wdelete_incomplete,
-			       "possible problem detected in invocation of "
-			       "%<operator delete%>"))
+		  if (warning_at (loc, OPT_Wdelete_incomplete,
+				  "possible problem detected in invocation of "
+				  "%<operator delete%>"))
 		    {
 		      cxx_incomplete_type_diagnostic (addr, type, DK_WARNING);
-		      inform (input_location,
+		      inform (loc,
 			      "neither the destructor nor the class-specific "
 			      "%<operator delete%> will be called, even if "
 			      "they are declared when the class is defined");
@@ -4877,15 +4880,15 @@  tree
 	      if (!dtor || !DECL_VINDEX (dtor))
 		{
 		  if (CLASSTYPE_PURE_VIRTUALS (type))
-		    warning (OPT_Wdelete_non_virtual_dtor,
-			     "deleting object of abstract class type %qT"
-			     " which has non-virtual destructor"
-			     " will cause undefined behavior", type);
+		    warning_at (loc, OPT_Wdelete_non_virtual_dtor,
+				"deleting object of abstract class type %qT"
+				" which has non-virtual destructor"
+				" will cause undefined behavior", type);
 		  else
-		    warning (OPT_Wdelete_non_virtual_dtor,
-			     "deleting object of polymorphic class type %qT"
-			     " which has non-virtual destructor"
-			     " might cause undefined behavior", type);
+		    warning_at (loc, OPT_Wdelete_non_virtual_dtor,
+				"deleting object of polymorphic class type %qT"
+				" which has non-virtual destructor"
+				" might cause undefined behavior", type);
 		}
 	    }
 	}
@@ -4984,7 +4987,10 @@  tree
     return error_mark_node;
 
   if (!deleting)
-    return expr;
+    {
+      protected_set_expr_location (expr, loc);
+      return expr;
+    }
 
   if (do_delete)
     {
@@ -5010,7 +5016,7 @@  tree
 
   /* Handle deleting a null pointer.  */
   warning_sentinel s (warn_address);
-  tree ifexp = cp_build_binary_op (input_location, NE_EXPR, addr,
+  tree ifexp = cp_build_binary_op (loc, NE_EXPR, addr,
 				   nullptr_node, complain);
   ifexp = cp_fully_fold (ifexp);
 
@@ -5024,6 +5030,7 @@  tree
   if (!integer_nonzerop (ifexp))
     expr = build3 (COND_EXPR, void_type_node, ifexp, expr, void_node);
 
+  protected_set_expr_location (expr, loc);
   return expr;
 }
 
@@ -5112,7 +5119,7 @@  push_base_cleanups (void)
 			       /*access_path=*/NULL_TREE,
 			       /*preserve_reference=*/false,
 			       tf_warning_or_error));
-	  expr = build_delete (this_type, this_member,
+	  expr = build_delete (input_location, this_type, this_member,
 			       sfk_complete_destructor,
 			       LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_NORMAL,
 			       0, tf_warning_or_error);
@@ -5139,7 +5146,7 @@  push_base_cleanups (void)
    be worth bothering.)  */
 
 tree
-build_vec_delete (tree base, tree maxindex,
+build_vec_delete (location_t loc, tree base, tree maxindex,
 		  special_function_kind auto_delete_vec,
 		  int use_global_delete, tsubst_flags_t complain)
 {
@@ -5162,7 +5169,7 @@  tree
 	  base = TARGET_EXPR_SLOT (base_init);
 	}
       type = strip_array_types (TREE_TYPE (type));
-      cookie_addr = fold_build1_loc (input_location, NEGATE_EXPR,
+      cookie_addr = fold_build1_loc (loc, NEGATE_EXPR,
 				 sizetype, TYPE_SIZE_UNIT (sizetype));
       cookie_addr = fold_build_pointer_plus (fold_convert (size_ptr_type, base),
 					     cookie_addr);
@@ -5186,15 +5193,17 @@  tree
   else
     {
       if (base != error_mark_node && !(complain & tf_error))
-	error ("type to vector delete is neither pointer or array type");
+	error_at (loc,
+		  "type to vector delete is neither pointer or array type");
       return error_mark_node;
     }
 
-  rval = build_vec_delete_1 (base, maxindex, type, auto_delete_vec,
+  rval = build_vec_delete_1 (loc, base, maxindex, type, auto_delete_vec,
 			     use_global_delete, complain);
   if (base_init && rval != error_mark_node)
     rval = build2 (COMPOUND_EXPR, TREE_TYPE (rval), base_init, rval);
 
+  protected_set_expr_location (rval, loc);
   return rval;
 }
 
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 279563)
+++ gcc/cp/parser.c	(working copy)
@@ -9046,9 +9046,8 @@  cp_parser_delete_expression (cp_parser* parser)
      the end at the end of the final token we consumed.  */
   location_t combined_loc = make_location (start_loc, start_loc,
 					   parser->lexer);
-  expression = delete_sanity (expression, NULL_TREE, array_p,
+  expression = delete_sanity (combined_loc, expression, NULL_TREE, array_p,
 			      global_scope_p, tf_warning_or_error);
-  protected_set_expr_location (expression, combined_loc);
 
   return expression;
 }
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 279563)
+++ gcc/cp/pt.c	(working copy)
@@ -19336,7 +19336,7 @@  tsubst_copy_and_build (tree t,
       {
 	tree op0 = RECUR (TREE_OPERAND (t, 0));
 	tree op1 = RECUR (TREE_OPERAND (t, 1));
-	RETURN (delete_sanity (op0, op1,
+	RETURN (delete_sanity (input_location, op0, op1,
 			       DELETE_EXPR_USE_VEC (t),
 			       DELETE_EXPR_USE_GLOBAL (t),
 			       complain));
Index: gcc/testsuite/g++.dg/init/delete1.C
===================================================================
--- gcc/testsuite/g++.dg/init/delete1.C	(revision 279563)
+++ gcc/testsuite/g++.dg/init/delete1.C	(working copy)
@@ -1,7 +1,9 @@ 
 // PR c++/19811
 
-class C; // { dg-message "forward" }
+class C; // { dg-message "7:forward" }
 
 void foo(void *p) {
-  delete [] ((C*)p) ; // { dg-warning "problem|incomplete" }
+  delete [] ((C*)p) ; // { dg-warning "3:possible problem detected in invocation of operator .delete \\\[\\\]." }
+  // { dg-message "3:neither the destructor nor the class-specific" "note" { target *-*-* } .-1 }
+  // { dg-warning "invalid use of incomplete type" "" { target *-*-* } .-2 }
 }
Index: gcc/testsuite/g++.dg/ipa/pr85607.C
===================================================================
--- gcc/testsuite/g++.dg/ipa/pr85607.C	(revision 279563)
+++ gcc/testsuite/g++.dg/ipa/pr85607.C	(working copy)
@@ -1,14 +1,14 @@ 
 // { dg-do compile }
 /* { dg-options "-O2" } */
 
-class A;	// { dg-message "forward declaration of 'class A'" }
+class A;	// { dg-message "7:forward declaration of 'class A'" }
 
-A *a;		// { dg-warning "'a' has incomplete type" }
+A *a;		// { dg-warning "4:'a' has incomplete type" }
 
 int
 main (int argc, char **argv)
 {
-  delete a;	// { dg-warning "delete" "warn" }
-  // { dg-message "note" "note" { target *-*-* } .-1 }
+  delete a;	// { dg-warning "3:possible problem detected in invocation of .operator delete." "warn" }
+  // { dg-message "3:neither the destructor nor the class-specific" "note" { target *-*-* } .-1 }
   return 0;
 }
Index: gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C
===================================================================
--- gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C	(revision 279563)
+++ gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C	(working copy)
@@ -1,7 +1,8 @@ 
 // PR c++/43452
 
-class Foo;         // { dg-message "forward" }
+class Foo;         // { dg-message "7:forward declaration" }
 int main() {
-   Foo* p;         // { dg-warning "incomplete" }
-   delete [] p;    // { dg-warning "problem" }
+   Foo* p;         // { dg-warning "9:.p. has incomplete type" }
+   delete [] p;    // { dg-warning "4:possible problem detected in invocation of operator .delete \\\[\\\]." }
+   // { dg-message "4:neither the destructor nor the class-specific" "note" { target *-*-* } .-1 }
 }
Index: gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C
===================================================================
--- gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C	(revision 279563)
+++ gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C	(working copy)
@@ -6,7 +6,7 @@  struct polyBase { virtual void f(); };
 void f(polyBase* p, polyBase* arr)
 {
   polyBase pb;
-  delete p;      // { dg-warning "non-virtual destructor might" }
+  delete p;      // { dg-warning "3:deleting \[^\n\r]* non-virtual destructor might" }
   delete [] arr;
 }
 
@@ -15,7 +15,7 @@  struct polyDerived : polyBase { };
 void f(polyDerived* p, polyDerived* arr)
 {
   polyDerived pd;
-  delete p;      // { dg-warning "non-virtual destructor might" }
+  delete p;      // { dg-warning "3:deleting \[^\n\r]* non-virtual destructor might" }
   delete [] arr;
 }
 
@@ -23,7 +23,7 @@  struct absDerived : polyBase { virtual void g() =
 
 void f(absDerived* p, absDerived* arr)
 {
-  delete p;      // { dg-warning "non-virtual destructor will" }
+  delete p;      // { dg-warning "3:deleting \[^\n\r]* non-virtual destructor will" }
   delete [] arr;
 }
 
@@ -51,7 +51,7 @@  struct polyBaseNonTrivial { ~polyBaseNonTrivial();
 void f(polyBaseNonTrivial* p, polyBaseNonTrivial* arr)
 {
   polyBaseNonTrivial pbnt;
-  delete p;      // { dg-warning "non-virtual destructor might" }
+  delete p;      // { dg-warning "3:deleting \[^\n\r]* non-virtual destructor might" }
   delete [] arr;
 }
 
@@ -60,7 +60,7 @@  struct polyDerivedNT : polyBaseNonTrivial { ~polyD
 void f(polyDerivedNT* p, polyDerivedNT* arr)
 {
   polyDerivedNT pdnt;
-  delete p;      // { dg-warning "non-virtual destructor might" }
+  delete p;      // { dg-warning "3:deleting \[^\n\r]* non-virtual destructor might" }
   delete [] arr;
 }
 
Index: gcc/testsuite/g++.dg/warn/incomplete1.C
===================================================================
--- gcc/testsuite/g++.dg/warn/incomplete1.C	(revision 279563)
+++ gcc/testsuite/g++.dg/warn/incomplete1.C	(working copy)
@@ -9,14 +9,14 @@ 
 // (But the deletion does not constitute an ill-formed program. So the
 // program should nevertheless compile, but it should give a warning.)
 
-class A;	// { dg-message "forward declaration of 'class A'" }
+class A;	// { dg-message "7:forward declaration of 'class A'" }
 
-A *a;		// { dg-warning "'a' has incomplete type" }
+A *a;		// { dg-warning "4:'a' has incomplete type" }
 
 int
 main (int argc, char **argv)
 {
-  delete a;	// { dg-warning "delete" "warn" }
-  // { dg-message "note" "note" { target *-*-* } .-1 }
+  delete a;	// { dg-warning "3:possible problem detected in invocation of .operator delete." "warn" }
+  // { dg-message "3:neither the destructor nor the class-specific" "note" { target *-*-* } .-1 }
   return 0;
 }
Index: libcc1/libcp1plugin.cc
===================================================================
--- libcc1/libcp1plugin.cc	(revision 279563)
+++ libcc1/libcp1plugin.cc	(working copy)
@@ -2812,7 +2812,8 @@  plugin_build_unary_expr (cc1_plugin::connection *s
 
     case DELETE_EXPR:
     case VEC_DELETE_EXPR:
-      result = delete_sanity (op0, NULL_TREE, opcode == VEC_DELETE_EXPR,
+      result = delete_sanity (input_location, op0, NULL_TREE,
+			      opcode == VEC_DELETE_EXPR,
 			      global_scope_p, tf_error);
       break;