===================================================================
@@ -1,3 +1,2 @@
template <typename T> struct B { typedef typename T::X X; };
-template <typename T> struct A { typedef B<T>::X::Y Z; }; // { dg-error "" }
-
+template <typename T> struct A { typedef B<T>::X::Y Z; }; // { dg-error "before 'B<T>::X::Y' because 'B<T>::X'" }
===================================================================
@@ -3270,9 +3270,21 @@ cp_parser_diagnose_invalid_type_name (cp_parser *p
}
else if (TYPE_P (parser->scope)
&& dependent_scope_p (parser->scope))
- error_at (location, "need %<typename%> before %<%T::%E%> because "
- "%qT is a dependent scope",
- parser->scope, id, parser->scope);
+ {
+ if (TREE_CODE (parser->scope) == TYPENAME_TYPE)
+ error_at (location,
+ "need %<typename%> before %<%T::%D::%E%> because "
+ "%<%T::%D%> is a dependent scope",
+ TYPE_CONTEXT (parser->scope),
+ TYPENAME_TYPE_FULLNAME (parser->scope),
+ id,
+ TYPE_CONTEXT (parser->scope),
+ TYPENAME_TYPE_FULLNAME (parser->scope));
+ else
+ error_at (location, "need %<typename%> before %<%T::%E%> because "
+ "%qT is a dependent scope",
+ parser->scope, id, parser->scope);
+ }
else if (TYPE_P (parser->scope))
{
if (!COMPLETE_TYPE_P (parser->scope))