new_arg = tsubst_template_arg (arg, args, complain, in_decl);
if (TYPE_P (new_arg))
new_arg = canonicalize_type_argument (new_arg, complain);
- if (TREE_CODE (new_arg) == TYPE_ARGUMENT_PACK)
+ }
+ if (TREE_CODE (new_arg) == TYPE_ARGUMENT_PACK)
+ {
+ tree pack_args = ARGUMENT_PACK_ARGS (new_arg);
+ for (int i = 0; i < TREE_VEC_LENGTH (pack_args); i++)
{
- tree pack_args = ARGUMENT_PACK_ARGS (new_arg);
- for (int i = 0; i < TREE_VEC_LENGTH (pack_args); i++)
- {
- tree& pack_arg = TREE_VEC_ELT (pack_args, i);
- if (TYPE_P (pack_arg))
- pack_arg = canonicalize_type_argument (pack_arg, complain);
- }
+ tree& pack_arg = TREE_VEC_ELT (pack_args, i);
+ if (TYPE_P (pack_arg))
+ pack_arg = canonicalize_type_argument (pack_arg, complain);
}
}
if (new_arg == error_mark_node)
tree
finish_requires_expr (location_t loc, tree parms, tree reqs)
{
- /* Modify the declared parameters by removing their context
- so they don't refer to the enclosing scope and explicitly
- indicating that they are constraint variables. */
- for (tree parm = parms; parm; parm = DECL_CHAIN (parm))
- {
- DECL_CONTEXT (parm) = NULL_TREE;
- CONSTRAINT_VAR_P (parm) = true;
- }
-
/* Build the node. */
tree r = build_min (REQUIRES_EXPR, boolean_type_node, parms, reqs, NULL_TREE);
TREE_SIDE_EFFECTS (r) = false;
if (!parens.require_close (parser))
return error_mark_node;
+ /* Modify the declared parameters by removing their context
+ so they don't refer to the enclosing scope and explicitly
+ indicating that they are constraint variables. */
+ for (tree parm = parms; parm; parm = TREE_CHAIN (parm))
+ {
+ if (parm == void_list_node || parm == explicit_void_list_node)
+ break;
+ tree decl = TREE_VALUE (parm);
+ DECL_CONTEXT (decl) = NULL_TREE;
+ CONSTRAINT_VAR_P (decl) = true;
+ }
+
return parms;
}
|| ((TREE_CODE (init) == COMPONENT_REF
|| TREE_CODE (init) == SCOPE_REF)
&& !REF_PARENTHESIZED_P (init)));
+ tree deduced = finish_decltype_type (init, id, complain);
+ deduced = canonicalize_type_argument (deduced, complain);
+ if (deduced == error_mark_node)
+ return error_mark_node;
targs = make_tree_vec (1);
- TREE_VEC_ELT (targs, 0)
- = finish_decltype_type (init, id, tf_warning_or_error);
+ TREE_VEC_ELT (targs, 0) = deduced;
+ /* FIXME: These errors ought to be diagnosed at parse time. */
if (type != auto_node)
{
if (complain & tf_error)
--- /dev/null
+// Verify that deduction failure of the decltype(auto) template parameter is
+// a SFINAE error.
+// { dg-do compile { target c++17 } }
+
+template <class> void f();
+template <class> void f(int);
+
+template <class T = int, decltype(auto) = &f<T>> void g();
+template <class = int> void g();
+
+int main() {
+ g();
+}