diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2019-12-30 13:23:40 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2019-12-30 13:23:40 +0000 |
commit | 04e4997a567142f56dc83eba67b9590c0431d7da (patch) | |
tree | 4e9336e6cb50d2d78040a5f54b7d2abb69f7a81a /gcc/cp/decl2.c | |
parent | 9332e5acbf0d79cda8321365a688fc22d7b5e261 (diff) | |
download | gcc-04e4997a567142f56dc83eba67b9590c0431d7da.zip gcc-04e4997a567142f56dc83eba67b9590c0431d7da.tar.gz gcc-04e4997a567142f56dc83eba67b9590c0431d7da.tar.bz2 |
decl2.c (delete_sanity): Add location_t parameter and use it throughout.
/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
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 6ff8113..5847e6b 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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); } |