diff options
author | Jason Merrill <jason@redhat.com> | 2016-04-28 15:01:13 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-04-28 15:01:13 -0400 |
commit | babaa9df0279b16243acc58c9a5d7731f4882af4 (patch) | |
tree | b72de2324ca719d4d3a1fc4ddc1c350892ee00d7 /gcc | |
parent | ceaaa9fe93fd5c33028b74eff376aff8321ecfa5 (diff) | |
download | gcc-babaa9df0279b16243acc58c9a5d7731f4882af4.zip gcc-babaa9df0279b16243acc58c9a5d7731f4882af4.tar.gz gcc-babaa9df0279b16243acc58c9a5d7731f4882af4.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 16 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 14 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.c | 3 | ||||
-rw-r--r-- | gcc/cp/except.c | 3 | ||||
-rw-r--r-- | gcc/cp/method.c | 8 | ||||
-rw-r--r-- | gcc/cp/tree.c | 7 |
8 files changed, 32 insertions, 30 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1219f82..ff6d30a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +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> diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f0307a3..6054d1a 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -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); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4c548c9..f6ea0b7 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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, diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 0d1048c..8c9d78b 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -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 diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index cc28045..3b52a35 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -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; diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 5336710..014df50 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -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); diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 862451f..0e501d9 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -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) diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5b5d5ba..97601aa 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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 |