* cvt.c (cp_get_fndecl_from_callee): Add fold parameter.
(cp_get_callee_fndecl_nofold): New.
* cp-gimplify.c (cp_genericize_r): Use it instead.
* call.c (check_self_delegation): Likewise.
From-SVN: r258689
+2018-03-20 Jason Merrill <jason@redhat.com>
+
+ PR c++/84978, ICE with NRVO.
+ * cvt.c (cp_get_fndecl_from_callee): Add fold parameter.
+ (cp_get_callee_fndecl_nofold): New.
+ * cp-gimplify.c (cp_genericize_r): Use it instead.
+ * call.c (check_self_delegation): Likewise.
+
2018-03-20 Nathan Sidwell <nathan@acm.org>
PR c++/84962
{
if (TREE_CODE (ret) == TARGET_EXPR)
ret = TARGET_EXPR_INITIAL (ret);
- tree fn = cp_get_callee_fndecl (ret);
+ tree fn = cp_get_callee_fndecl_nofold (ret);
if (fn && DECL_ABSTRACT_ORIGIN (fn) == current_function_decl)
error ("constructor delegates to itself");
}
version is inlinable, a direct call to this version can be made
otherwise the call should go through the dispatcher. */
{
- tree fn = cp_get_callee_fndecl (stmt);
+ tree fn = cp_get_callee_fndecl_nofold (stmt);
if (fn && DECL_FUNCTION_VERSIONED (fn)
&& (current_function_decl == NULL
|| !targetm.target_option.can_inline_p (current_function_decl,
extern tree cp_fold_convert (tree, tree);
extern tree cp_get_callee (tree);
extern tree cp_get_callee_fndecl (tree);
-extern tree cp_get_fndecl_from_callee (tree);
+extern tree cp_get_callee_fndecl_nofold (tree);
+extern tree cp_get_fndecl_from_callee (tree, bool fold = true);
extern tree convert_to_void (tree, impl_conv_void,
tsubst_flags_t);
extern tree convert_force (tree, tree, int,
if we can. */
tree
-cp_get_fndecl_from_callee (tree fn)
+cp_get_fndecl_from_callee (tree fn, bool fold /* = true */)
{
if (fn == NULL_TREE)
return fn;
if (type == unknown_type_node)
return NULL_TREE;
gcc_assert (POINTER_TYPE_P (type));
- fn = maybe_constant_init (fn);
+ if (fold)
+ fn = maybe_constant_init (fn);
STRIP_NOPS (fn);
if (TREE_CODE (fn) == ADDR_EXPR)
{
return cp_get_fndecl_from_callee (cp_get_callee (call));
}
+/* As above, but not using the constexpr machinery. */
+
+tree
+cp_get_callee_fndecl_nofold (tree call)
+{
+ return cp_get_fndecl_from_callee (cp_get_callee (call), false);
+}
+
/* Subroutine of convert_to_void. Warn if we're discarding something with
attribute [[nodiscard]]. */