decl2.c (delete_sanity): Add location_t parameter and use it throughout.
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 30 Dec 2019 13:23:40 +0000 (13:23 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 30 Dec 2019 13:23:40 +0000 (13:23 +0000)
/gcc/cp
2019-12-30  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-30  Paolo Carlini  <paolo.carlini@oracle.com>

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

/gcc/testsuite
2019-12-30  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.

From-SVN: r279768

15 files changed:
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/init.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/delete1.C
gcc/testsuite/g++.dg/ipa/pr85607.C
gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C
gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C
gcc/testsuite/g++.dg/warn/incomplete1.C
libcc1/ChangeLog
libcc1/libcp1plugin.cc

index 37d776c2aee95d0c9331b50c18c8ab84567b42be..9c30253f09480e63cd8524679ddf58deb266900c 100644 (file)
@@ -1,3 +1,19 @@
+2019-12-30  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.
+
 2019-12-29  Marek Polacek  <polacek@redhat.com>
 
        PR c++/88337 - Implement P1327R1: Allow dynamic_cast in constexpr.
index 50cd2837010500b56ee43610af66fe19b9aee9af..4b92829232ad8b7905acbb3355ac4419282a2d83 100644 (file)
@@ -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> **, tree, tree,
 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 c15cbfa3bd3532fa86ca5bcc6a75dde633e922a4..2760dba5be52ec9fcb5daff3cad64306283bea3a 100644 (file)
@@ -17310,7 +17310,7 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain)
       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 6ff81136c5817bc481e66e03d20f2b313d8e4d93..5847e6b0840dc7c3f4329d617e6203339811b9fd 100644 (file)
@@ -475,8 +475,8 @@ grok_array_decl (location_t loc, tree array_expr, tree index_exp,
    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,21 +489,23 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete,
       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);
 
   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 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete,
   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,21 +529,21 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete,
   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;
     }
 
   /* 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 6f4c918d5604e3311f33a435c4e2cb8ed4d87b99..5b48a0e3a1c0dc6d35493da134c38acce6dfa7e1 100644 (file)
@@ -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, tree nelts,
 }
 \f
 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 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
   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 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
       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 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
       /* 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,30 +4008,30 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
 
   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;
 
   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 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
          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 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
     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 init,
                                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 dtor_kind, int flags,
    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 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
       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 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
        {
          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 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
              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 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
              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 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
     return error_mark_node;
 
   if (!deleting)
-    return expr;
+    {
+      protected_set_expr_location (expr, loc);
+      return expr;
+    }
 
   if (do_delete)
     {
@@ -5010,7 +5016,7 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
 
   /* 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 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
   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 @@ build_vec_delete (tree base, tree maxindex,
          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 @@ build_vec_delete (tree base, tree maxindex,
   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 c66ef34a948593ea7fc70b12c9ca8de013064a1d..2e39107913cb50d6e0cf708a2e36fcd26b808b91 100644 (file)
@@ -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 dc01774d203644a28dd23d90bfdd9ce4ed0f2f06..7f8ce1d3310e393381228ef26fd9fd2749b4cf3e 100644 (file)
@@ -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 0695fb90a6dbf0b474d24c183b7a6967e15e47ef..103b68f3b6dc18f91009e6d1fcefb7e42ac123a1 100644 (file)
@@ -1,3 +1,11 @@
+2019-12-30  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.
+
 2019-12-30  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/91651
index 8236abcd6fe262bce6d861b003e61d9618aac452..617c7ba8a101ce8d6edcc56eb230bbe82bb8618c 100644 (file)
@@ -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 b47aba2167d39a6dfe412326718136b31a111daf..9f6190961522e80691145da894894154f152b1fd 100644 (file)
@@ -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 729ea21017bf81425e6e50651aee7ec33b8a1e41..d0c40e23db93f62f6508f993a994a133a8f83189 100644 (file)
@@ -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 f5727ea90a03b12c0e17933ff745875b1ee7f7b0..7f892d30b72c2f5f29bdb2d770318022ba6500cb 100644 (file)
@@ -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() = 0; };
 
 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(); virtual void f(); };
 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 { ~polyDerivedNT(); };
 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 8f21f7bfa3fb539591c625136d5133083708c226..aa44c7ba3fb76bb4c7e9f66bb9a89d6f3a5d6596 100644 (file)
@@ -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 a56deb5a9db4d92e5ca446c942b7fe50d30bcac3..21622bdd67566d813cac7fd5632036680927334a 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-30  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * libcp1plugin.cc (plugin_build_unary_expr): Update delete_sanity
+       call.
+
 2019-12-18  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * libcp1plugin.cc (plugin_build_unary_expr): Update build_throw
index 56eaf9b4f1410dc2c7a7822f3612a507665163c2..aae19acffc8e74b3efb4e730a36825c696eadb25 100644 (file)
@@ -2812,7 +2812,8 @@ plugin_build_unary_expr (cc1_plugin::connection *self,
 
     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;