===================================================================
@@ -0,0 +1,26 @@
+// PR c++/46046
+
+template <class T>
+ struct foo
+{
+ template <class U, class V = void>
+ struct type
+ {};
+
+ template <class V>
+ struct type<
+ typename T::template some_type<int>,
+ V
+ >
+ {};
+};
+
+template <class T>
+ class bar
+{};
+
+int main()
+{
+ typedef foo<bar<int> > cont;
+ cont::type<char> obj; // { dg-error "cannot be defined" }
+}
===================================================================
@@ -490,7 +490,7 @@ add_to_template_args (tree args, tree extra_args)
int i;
int j;
- if (args == NULL_TREE)
+ if (args == NULL_TREE || extra_args == error_mark_node)
return extra_args;
extra_depth = TMPL_ARGS_DEPTH (extra_args);
@@ -5970,6 +5970,9 @@ coerce_template_parms (tree parms,
parameters. */
int variadic_p = 0;
+ if (args == error_mark_node)
+ return error_mark_node;
+
nparms = TREE_VEC_LENGTH (parms);
/* Determine if there are any parameter packs. */