Commit babaa9df by Jason Merrill Committed by Jason Merrill

cvt.c (cp_get_callee): New.

	* cvt.c (cp_get_callee): New.

	* constexpr.c (get_function_named_in_call): Use it.
	* cxx-pretty-print.c (postfix_expression): Use it.
	* except.c (check_noexcept_r): Use it.
	* method.c (check_nontriv): Use it.
	* tree.c (build_aggr_init_expr): Use it.
	* cp-tree.h: Declare it.

From-SVN: r235596
parent ceaaa9fe
2016-04-28 Jason Merrill <jason@redhat.com>
* cvt.c (cp_get_callee): New.
* constexpr.c (get_function_named_in_call): Use it.
* cxx-pretty-print.c (postfix_expression): Use it.
* except.c (check_noexcept_r): Use it.
* method.c (check_nontriv): Use it.
* tree.c (build_aggr_init_expr): Use it.
* cp-tree.h: Declare it.
2015-04-27 Ryan Burn <contact@rnburn.com>
Jeff Law <law@redhat.com>
......
......@@ -1044,21 +1044,7 @@ save_fundef_copy (tree fun, tree copy)
static tree
get_function_named_in_call (tree t)
{
tree fun = NULL;
switch (TREE_CODE (t))
{
case CALL_EXPR:
fun = CALL_EXPR_FN (t);
break;
case AGGR_INIT_EXPR:
fun = AGGR_INIT_EXPR_FN (t);
break;
default:
gcc_unreachable();
break;
}
tree fun = cp_get_callee (t);
if (fun && TREE_CODE (fun) == ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (fun, 0)) == FUNCTION_DECL)
fun = TREE_OPERAND (fun, 0);
......
......@@ -5694,6 +5694,7 @@ extern tree ocp_convert (tree, tree, int, int,
extern tree cp_convert (tree, tree, tsubst_flags_t);
extern tree cp_convert_and_check (tree, tree, tsubst_flags_t);
extern tree cp_fold_convert (tree, tree);
extern tree cp_get_callee (tree);
extern tree convert_to_void (tree, impl_conv_void,
tsubst_flags_t);
extern tree convert_force (tree, tree, int,
......
......@@ -904,6 +904,20 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
return error_mark_node;
}
/* If CALL is a call, return the callee; otherwise null. */
tree
cp_get_callee (tree call)
{
if (call == NULL_TREE)
return call;
else if (TREE_CODE (call) == CALL_EXPR)
return CALL_EXPR_FN (call);
else if (TREE_CODE (call) == AGGR_INIT_EXPR)
return AGGR_INIT_EXPR_FN (call);
return NULL_TREE;
}
/* When an expression is used in a void context, its value is discarded and
no lvalue-rvalue and similar conversions happen [expr.static.cast/4,
stmt.expr/1, expr.comma/1]. This permits dereferencing an incomplete type
......
......@@ -490,8 +490,7 @@ cxx_pretty_printer::postfix_expression (tree t)
case AGGR_INIT_EXPR:
case CALL_EXPR:
{
tree fun = (code == AGGR_INIT_EXPR ? AGGR_INIT_EXPR_FN (t)
: CALL_EXPR_FN (t));
tree fun = cp_get_callee (t);
tree saved_scope = enclosing_scope;
bool skipfirst = false;
tree arg;
......
......@@ -1158,8 +1158,7 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/)
translation unit, creating ODR problems.
We could use TREE_NOTHROW (t) for !TREE_PUBLIC fns, though... */
tree fn = (code == AGGR_INIT_EXPR
? AGGR_INIT_EXPR_FN (t) : CALL_EXPR_FN (t));
tree fn = cp_get_callee (t);
tree type = TREE_TYPE (fn);
gcc_assert (POINTER_TYPE_P (type));
type = TREE_TYPE (type);
......
......@@ -1002,12 +1002,8 @@ get_inherited_ctor (tree ctor)
static tree
check_nontriv (tree *tp, int *, void *)
{
tree fn;
if (TREE_CODE (*tp) == CALL_EXPR)
fn = CALL_EXPR_FN (*tp);
else if (TREE_CODE (*tp) == AGGR_INIT_EXPR)
fn = AGGR_INIT_EXPR_FN (*tp);
else
tree fn = cp_get_callee (*tp);
if (fn == NULL_TREE)
return NULL_TREE;
if (TREE_CODE (fn) == ADDR_EXPR)
......
......@@ -470,11 +470,8 @@ build_aggr_init_expr (tree type, tree init)
if (processing_template_decl)
return init;
if (TREE_CODE (init) == CALL_EXPR)
fn = CALL_EXPR_FN (init);
else if (TREE_CODE (init) == AGGR_INIT_EXPR)
fn = AGGR_INIT_EXPR_FN (init);
else
fn = cp_get_callee (init);
if (fn == NULL_TREE)
return convert (type, init);
is_ctor = (TREE_CODE (fn) == ADDR_EXPR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment