aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/except.c
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-12-18 19:23:01 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-12-18 19:23:01 +0000
commitd3769410c65a7d3f2d58402c3ecf5c253e340c2e (patch)
treeb4db956e077c48a691a959e453a8afb0aa65b4cf /gcc/cp/except.c
parenta7389ce5d4505a7a3596539ad3a844a850e769d4 (diff)
downloadgcc-d3769410c65a7d3f2d58402c3ecf5c253e340c2e.zip
gcc-d3769410c65a7d3f2d58402c3ecf5c253e340c2e.tar.gz
gcc-d3769410c65a7d3f2d58402c3ecf5c253e340c2e.tar.bz2
typeck.c (cxx_sizeof_or_alignof_type): Add location_t parameter and use it throughout.
/gcc/cp 2019-12-18 Paolo Carlini <paolo.carlini@oracle.com> * typeck.c (cxx_sizeof_or_alignof_type): Add location_t parameter and use it throughout. (cxx_sizeof_expr): Likewise. (cxx_alignof_expr): Likewise. (cxx_sizeof_or_alignof_expr): Likewise. (cxx_alignas_expr): Update call. * decl.c (fold_sizeof_expr): Likewise. * pt.c (tsubst_copy): Likewise. (tsubst_copy_and_build): Likewise. * except.c (build_throw): Add location_t parameter and use it. (expand_end_catch_block): Update call. * parser.c (cp_parser_unary_expression): Update cxx_sizeof_or_alignof_type and cxx_sizeof_or_alignof_expr calls, pass the compound location. (cp_parser_throw_expression): Likewise pass the combined location to build_throw. * cp-tree.h: Update declarations. * semantics.c (finish_handler_parms): Use DECL_SOURCE_LOCATION. * decl2.c (check_classfn): Likewise. * except.c (is_admissible_throw_operand_or_catch_parameter): Exploit cp_expr_loc_or_input_loc in one place. * except.c (create_try_catch_expr): Remove, unused. /libcc1 2019-12-18 Paolo Carlini <paolo.carlini@oracle.com> * libcp1plugin.cc (plugin_build_unary_expr): Update build_throw and cxx_sizeof_or_alignof_expr calls. (plugin_build_unary_type_expr): Likewise for cxx_sizeof_or_alignof_type. /gcc/testsuite 2019-12-18 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/diagnostic/alignof2.C: New. * g++.dg/diagnostic/alignof3.C: Likewise. * g++.dg/diagnostic/incomplete-type-1.C: Likewise. * g++.dg/warn/Wcatch-value-3b.C: Likewise. * g++.dg/cpp0x/alignof3.C: Check location(s) too. * g++.dg/cpp1z/decomp-bitfield1.C: Likewise. * g++.dg/cpp1z/has-unique-obj-representations2.C: Likewise. * g++.dg/expr/sizeof3.C: Likewise. * g++.dg/ext/flexary6.C: Likewise. * g++.dg/ext/vla4.C: Likewise. * g++.dg/template/sizeof11.C: Likewise. * g++.dg/warn/Wcatch-value-1.C: Likewise. * g++.dg/warn/Wcatch-value-2.C: Likewise. * g++.dg/warn/Wcatch-value-3.C: Likewise. * g++.old-deja/g++.brendan/sizeof1.C: Likewise. * g++.old-deja/g++.brendan/sizeof3.C: Likewise. * g++.old-deja/g++.brendan/sizeof4.C: Likewise. * g++.old-deja/g++.eh/ctor1.C: Likewise. * g++.old-deja/g++.jason/ambig1.C: Likewise. * g++.old-deja/g++.other/sizeof4.C: Likewise. From-SVN: r279543
Diffstat (limited to 'gcc/cp/except.c')
-rw-r--r--gcc/cp/except.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 8bc831d..e385c67 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -507,7 +507,7 @@ expand_end_catch_block (void)
&& (DECL_CONSTRUCTOR_P (current_function_decl)
|| DECL_DESTRUCTOR_P (current_function_decl)))
{
- tree rethrow = build_throw (NULL_TREE);
+ tree rethrow = build_throw (input_location, NULL_TREE);
TREE_NO_WARNING (rethrow) = true;
finish_expr_stmt (rethrow);
}
@@ -627,7 +627,7 @@ wrap_cleanups_r (tree *tp, int *walk_subtrees, void * /*data*/)
/* Build a throw expression. */
tree
-build_throw (tree exp)
+build_throw (location_t loc, tree exp)
{
if (exp == error_mark_node)
return exp;
@@ -637,12 +637,13 @@ build_throw (tree exp)
if (cfun)
current_function_returns_abnormally = 1;
exp = build_min (THROW_EXPR, void_type_node, exp);
- SET_EXPR_LOCATION (exp, input_location);
+ SET_EXPR_LOCATION (exp, loc);
return exp;
}
if (exp && null_node_p (exp))
- warning (0, "throwing NULL, which has integral, not pointer type");
+ warning_at (loc, 0,
+ "throwing NULL, which has integral, not pointer type");
if (exp != NULL_TREE)
{
@@ -758,6 +759,7 @@ build_throw (tree exp)
{
int flags = LOOKUP_NORMAL | LOOKUP_ONLYCONVERTING;
bool converted = false;
+ location_t exp_loc = cp_expr_loc_or_loc (exp, loc);
/* Under C++0x [12.8/16 class.copy], a thrown lvalue is sometimes
treated as an rvalue for the purposes of overload resolution
@@ -790,7 +792,7 @@ build_throw (tree exp)
if (exp == error_mark_node)
{
- error (" in thrown expression");
+ inform (exp_loc, " in thrown expression");
return error_mark_node;
}
}
@@ -867,8 +869,7 @@ build_throw (tree exp)
exp = cp_build_function_call_vec (rethrow_fn, NULL, tf_warning_or_error);
}
- exp = build1 (THROW_EXPR, void_type_node, exp);
- SET_EXPR_LOCATION (exp, input_location);
+ exp = build1_loc (loc, THROW_EXPR, void_type_node, exp);
return exp;
}
@@ -948,8 +949,9 @@ is_admissible_throw_operand_or_catch_parameter (tree t, bool is_throw)
else if (variably_modified_type_p (type, NULL_TREE))
{
if (is_throw)
- error ("cannot throw expression of type %qT because it involves "
- "types of variable size", type);
+ error_at (cp_expr_loc_or_input_loc (expr),
+ "cannot throw expression of type %qT because it involves "
+ "types of variable size", type);
else
error ("cannot catch type %qT because it involves types of "
"variable size", type);
@@ -1321,22 +1323,4 @@ build_noexcept_spec (tree expr, tsubst_flags_t complain)
}
}
-/* Returns a TRY_CATCH_EXPR that will put TRY_LIST and CATCH_LIST in the
- TRY and CATCH locations. CATCH_LIST must be a STATEMENT_LIST */
-
-tree
-create_try_catch_expr (tree try_expr, tree catch_list)
-{
- location_t loc = EXPR_LOCATION (try_expr);
-
- append_to_statement_list (do_begin_catch (), &catch_list);
- append_to_statement_list (build_throw (NULL_TREE), &catch_list);
- tree catch_tf_expr = build_stmt (loc, TRY_FINALLY_EXPR, catch_list,
- do_end_catch (NULL_TREE));
- catch_list = build2 (CATCH_EXPR, void_type_node, NULL_TREE,
- catch_tf_expr);
- tree try_catch_expr = build_stmt (loc, TRY_CATCH_EXPR, try_expr, catch_list);
- return try_catch_expr;
-}
-
#include "gt-cp-except.h"