From 11249cf0df9d2a868a09a49d12586c3c08823392 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 9 Apr 1999 16:05:47 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 5 +++ gcc/cp/decl.c | 9 ++++++ gcc/testsuite/g++.old-deja/g++.pt/crash36.C | 35 +++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/crash36.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8a85396b402..6c64951ac7f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1999-04-09 Mark Mitchell + + * 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 * decl.c (start_decl): Pass attributes to grokdeclarator. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e50c90a22cd..1ee61fc7c53 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash36.C b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C new file mode 100644 index 00000000000..b5281c32b61 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C @@ -0,0 +1,35 @@ +// Build don't link: +// Origin: Andreas Kloeckner + +template struct iterator_traits { + typedef typename Iterator::iterator_category + iterator_category; // ERROR - no type iterator_category +}; + +template +struct iterator { + typedef Category iterator_category; +}; + + +template +struct reverse_iterator : public +iterator::iterator_category> { + protected: + Iterator current; + +}; +class tag { }; + +template +struct list { + template + struct list_iterator { + }; + + reverse_iterator > rbegin() + { return reverse_iterator > // ERROR - no type + (list_iterator(Head->next())); } // ERROR - instantiated here +}; + +template class list; // ERROR - instantiated from here