decl.c (make_typename_type): Complain if we don't find a type when trying to make a typename type for a...

* decl.c (make_typename_type): Complain if we don't find a type
	when trying to make a typename type for a non-template type.

From-SVN: r26317
This commit is contained in:
Mark Mitchell 1999-04-09 16:05:47 +00:00 committed by Mark Mitchell
parent 92c7ee702f
commit 11249cf0df
3 changed files with 49 additions and 0 deletions

View File

@ -1,3 +1,8 @@
1999-04-09 Mark Mitchell <mark@codesourcery.com>
* decl.c (make_typename_type): Complain if we don't find a type
when trying to make a typename type for a non-template type.
1999-04-09 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (start_decl): Pass attributes to grokdeclarator.

View File

@ -5373,6 +5373,15 @@ make_typename_type (context, name)
return TREE_TYPE (t);
}
}
/* If the CONTEXT is not a template type, then either the field is
there now or its never going to be. */
if (!uses_template_parms (context) && !t)
{
cp_error ("no type named `%#T' in `%#T'", name, context);
return error_mark_node;
}
return build_typename_type (context, name, fullname, NULL_TREE);
}

View File

@ -0,0 +1,35 @@
// Build don't link:
// Origin: Andreas Kloeckner <ak@ixion.net>
template<class Iterator> struct iterator_traits {
typedef typename Iterator::iterator_category
iterator_category; // ERROR - no type iterator_category
};
template<class Category>
struct iterator {
typedef Category iterator_category;
};
template <class Iterator>
struct reverse_iterator : public
iterator<typename iterator_traits<Iterator>::iterator_category> {
protected:
Iterator current;
};
class tag { };
template <class T>
struct list {
template <class Item>
struct list_iterator {
};
reverse_iterator<list_iterator<T> > rbegin()
{ return reverse_iterator<list_iterator<T> > // ERROR - no type
(list_iterator<T>(Head->next())); } // ERROR - instantiated here
};
template class list<int>; // ERROR - instantiated from here