aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-04-09 16:05:47 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-04-09 16:05:47 +0000
commit11249cf0df9d2a868a09a49d12586c3c08823392 (patch)
treec67c2500bcdadcacde0c09a6727dffd0b3a1b068 /gcc
parent92c7ee702fc7b9e239a412325621e88c6cbd23f1 (diff)
downloadgcc-11249cf0df9d2a868a09a49d12586c3c08823392.zip
gcc-11249cf0df9d2a868a09a49d12586c3c08823392.tar.gz
gcc-11249cf0df9d2a868a09a49d12586c3c08823392.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c9
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/crash36.C35
3 files changed, 49 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8a85396..6c64951 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e50c90a..1ee61fc 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 0000000..b5281c3
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C
@@ -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