* decl.c (make_typename_type): Tighten error-checking.

From-SVN: r26586
This commit is contained in:
Mark Mitchell 1999-04-22 16:26:44 +00:00 committed by Mark Mitchell
parent c9eb638ec7
commit ad810b22b8
3 changed files with 27 additions and 6 deletions

View File

@ -1,3 +1,7 @@
1999-04-22 Mark Mitchell <mark@codesourcery.com>
* decl.c (make_typename_type): Tighten error-checking.
1999-04-20 Mark Mitchell <mark@codesourcery.com> 1999-04-20 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (build_binary_op): Remove unneeded parameter. * cp-tree.h (build_binary_op): Remove unneeded parameter.

View File

@ -5385,19 +5385,20 @@ make_typename_type (context, name)
{ {
if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR) if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR)
{ {
tree tmpl = NULL_TREE;
if (IS_AGGR_TYPE (context)) if (IS_AGGR_TYPE (context))
t = lookup_field (context, name, 0, 0); tmpl = lookup_field (context, name, 0, 0);
else if (!tmpl || !DECL_CLASS_TEMPLATE_P (tmpl))
{ {
cp_error ("no class template named `%#T' in `%#T'", cp_error ("no class template named `%#T' in `%#T'",
name, context); name, context);
return error_mark_node; return error_mark_node;
} }
if (t && DECL_CLASS_TEMPLATE_P (t)) return lookup_template_class (tmpl,
return lookup_template_class (t, TREE_OPERAND (fullname, 1), TREE_OPERAND (fullname, 1),
NULL_TREE, context, NULL_TREE, context,
/*entering_scope=*/0); /*entering_scope=*/0);
} }
else else
{ {

View File

@ -0,0 +1,16 @@
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T>
struct S {
typedef typename T::Y<T>::Z X; // ERROR - No Y in A
X x; // ERROR - No Y in A
};
struct A {
struct Y {
typedef A Z;
};
};
template struct S<A>;