@@ -12226,8 +12226,7 @@ instantiate_class_template (tree type)
return error_mark_node;
if (COMPLETE_OR_OPEN_TYPE_P (type)
- || (uses_template_parms (type)
- && !TYPE_FUNCTION_SCOPE_P (type)))
+ || uses_template_parms (type))
return type;
/* Figure out which template is being instantiated. */
@@ -18893,7 +18892,10 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl)
case TAG_DEFN:
tmp = tsubst (TREE_TYPE (t), args, complain, NULL_TREE);
- if (CLASS_TYPE_P (tmp))
+ if (dependent_type_p (tmp))
+ /* This is a partial instantiation, try again when full. */
+ add_stmt (build_min (TAG_DEFN, tmp));
+ else if (CLASS_TYPE_P (tmp))
{
/* Local classes are not independent templates; they are
instantiated along with their containing function. And this
@@ -18902,12 +18904,6 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl)
/* Closures are handled by the LAMBDA_EXPR. */
gcc_assert (!LAMBDA_TYPE_P (TREE_TYPE (t)));
complete_type (tmp);
- if (dependent_type_p (tmp))
- {
- /* This is a partial instantiation, try again when full. */
- add_stmt (build_min (TAG_DEFN, tmp));
- break;
- }
tree save_ccp = current_class_ptr;
tree save_ccr = current_class_ref;
for (tree fld = TYPE_FIELDS (tmp); fld; fld = DECL_CHAIN (fld))
new file mode 100644
@@ -0,0 +1,11 @@
+// PR c++/113544
+// { dg-do compile { target c++14 } }
+
+template<class T>
+void f() {
+ [](auto parm) {
+ struct type : decltype(parm) { };
+ };
+}
+
+template void f<int>();