+2016-10-10 Jason Merrill <jason@redhat.com>
+
+ PR c++/77890
+ PR c++/77912
+ * pt.c (do_class_deduction): Set cp_unevaluated_operand.
+ (tsubst) [TEMPLATE_TYPE_PARM]: Copy CLASS_PLACEHOLDER_TEMPLATE.
+
2016-10-08 Jason Merrill <jason@redhat.com>
* cp-gimplify.c (cp_fold): Add variable name.
TYPE_POINTER_TO (r) = NULL_TREE;
TYPE_REFERENCE_TO (r) = NULL_TREE;
- /* Propagate constraints on placeholders. */
if (TREE_CODE (t) == TEMPLATE_TYPE_PARM)
- if (tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (t))
- PLACEHOLDER_TYPE_CONSTRAINTS (r)
- = tsubst_constraint (constr, args, complain, in_decl);
+ {
+ /* Propagate constraints on placeholders. */
+ if (tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (t))
+ PLACEHOLDER_TYPE_CONSTRAINTS (r)
+ = tsubst_constraint (constr, args, complain, in_decl);
+ else if (tree pl = CLASS_PLACEHOLDER_TEMPLATE (t))
+ CLASS_PLACEHOLDER_TEMPLATE (r) = pl;
+ }
if (TREE_CODE (r) == TEMPLATE_TEMPLATE_PARM)
/* We have reduced the level of the template
return error_mark_node;
}
+ ++cp_unevaluated_operand;
tree t = build_new_function_call (cands, &args, /*koenig*/false,
complain|tf_decltype);
-
+ --cp_unevaluated_operand;
release_tree_vector (args);
return TREE_TYPE (t);
--- /dev/null
+// PR c++/77912
+// { dg-options -std=c++1z }
+
+template<class T> struct S{S(T){}};
+
+//error: invalid use of template type parameter 'S'
+template<class T> auto f(T t){return S(t);}
+
+int main()
+{
+ //fails
+ f(42);
+
+ //fails
+ //error: invalid use of template type parameter 'S'
+ [](auto a){return S(a);}(42);
+
+ //works
+ [](int a){return S(a);}(42);
+}
--- /dev/null
+// PR c++/77890
+// { dg-options -std=c++1z }
+
+template<class F> struct S{S(F&&f){}};
+void f()
+{
+ S([]{});
+}
+
+template <typename TF>
+struct scope_guard : TF
+{
+ scope_guard(TF f) : TF{f} { }
+ ~scope_guard() { (*this)(); }
+};
+
+void g()
+{
+ struct K { void operator()() {} };
+ scope_guard _{K{}};
+}