===================================================================
@@ -10741,19 +10741,23 @@ tsubst_decl (tree t, tree args, tsubst_flags_t com
tree type = NULL_TREE;
bool local_p;
- if (TREE_CODE (t) == TYPE_DECL
- && t == TYPE_MAIN_DECL (TREE_TYPE (t)))
+ if (TREE_CODE (t) == TYPE_DECL)
{
- /* If this is the canonical decl, we don't have to
- mess with instantiations, and often we can't (for
- typename, template type parms and such). Note that
- TYPE_NAME is not correct for the above test if
- we've copied the type for a typedef. */
- type = tsubst (TREE_TYPE (t), args, complain, in_decl);
- if (type == error_mark_node)
+ if (TREE_TYPE (t) == error_mark_node)
RETURN (error_mark_node);
- r = TYPE_NAME (type);
- break;
+ else if (t == TYPE_MAIN_DECL (TREE_TYPE (t)))
+ {
+ /* If this is the canonical decl, we don't have to
+ mess with instantiations, and often we can't (for
+ typename, template type parms and such). Note that
+ TYPE_NAME is not correct for the above test if
+ we've copied the type for a typedef. */
+ type = tsubst (TREE_TYPE (t), args, complain, in_decl);
+ if (type == error_mark_node)
+ RETURN (error_mark_node);
+ r = TYPE_NAME (type);
+ break;
+ }
}
/* Check to see if we already have the specialization we
===================================================================
@@ -0,0 +1,6 @@
+// PR c++/58448
+
+class SmallVector; struct Types4;
+template <typename, typename, typename, typename> struct Types {
+ typedef Types4<>::Constructable // { dg-error "template|typedef|expected" }
+} Types<SmallVector, SmallVector, SmallVector, SmallVector>:: > // { dg-error "expected" }