2019-01-17 Jason Merrill <jason@redhat.com>
+ PR c++/86205 - ICE with ?: of throw and template-id.
+ * pt.c (resolve_nondeduced_context_or_error): Split out from...
+ * typeck.c (decay_conversion): ...here.
+ * call.c (build_conditional_expr_1): Use it.
+
PR c++/86740, ICE with constexpr if and nested generic lambdas.
* tree.c (cp_walk_subtrees): Handle LAMBDA_EXPR.
arg3_type = unlowered_expr_type (arg3);
if (VOID_TYPE_P (arg2_type) || VOID_TYPE_P (arg3_type))
{
+ /* 'void' won't help in resolving an overloaded expression on the
+ other side, so require it to resolve by itself. */
+ if (arg2_type == unknown_type_node)
+ {
+ arg2 = resolve_nondeduced_context_or_error (arg2, complain);
+ arg2_type = TREE_TYPE (arg2);
+ }
+ if (arg3_type == unknown_type_node)
+ {
+ arg3 = resolve_nondeduced_context_or_error (arg3, complain);
+ arg3_type = TREE_TYPE (arg3);
+ }
+
/* [expr.cond]
One of the following shall hold:
extern tree get_template_argument_pack_elems (const_tree);
extern tree get_function_template_decl (const_tree);
extern tree resolve_nondeduced_context (tree, tsubst_flags_t);
+extern tree resolve_nondeduced_context_or_error (tree, tsubst_flags_t);
extern hashval_t iterative_hash_template_arg (tree arg, hashval_t val);
extern tree coerce_template_parms (tree, tree, tree);
extern tree coerce_template_parms (tree, tree, tree, tsubst_flags_t);
return orig_expr;
}
+/* As above, but error out if the expression remains overloaded. */
+
+tree
+resolve_nondeduced_context_or_error (tree exp, tsubst_flags_t complain)
+{
+ exp = resolve_nondeduced_context (exp, complain);
+ if (type_unknown_p (exp))
+ {
+ if (complain & tf_error)
+ cxx_incomplete_type_error (exp, TREE_TYPE (exp));
+ return error_mark_node;
+ }
+ return exp;
+}
+
/* Subroutine of resolve_overloaded_unification; does deduction for a single
overload. Fills TARGS with any deduced arguments, or error_mark_node if
different overloads deduce different arguments for a given parm.
if (type == error_mark_node)
return error_mark_node;
- exp = resolve_nondeduced_context (exp, complain);
- if (type_unknown_p (exp))
- {
- if (complain & tf_error)
- cxx_incomplete_type_error (exp, TREE_TYPE (exp));
- return error_mark_node;
- }
+ exp = resolve_nondeduced_context_or_error (exp, complain);
code = TREE_CODE (type);
--- /dev/null
+// PR c++/86205
+// { dg-do compile { target c++11 } }
+
+bool b;
+
+template < class T > int f ()
+{
+ return 0;
+}
+
+template < class T > auto g () -> decltype (b ? f < int > : throw 0)
+{
+ return b ? f<int> : throw 0;
+}