]> gcc.gnu.org Git - gcc.git/commitdiff
decl.c (make_typename_type): Complain if we don't find a type when trying to make...
authorMark Mitchell <mark@codesourcery.com>
Fri, 9 Apr 1999 16:05:47 +0000 (16:05 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 9 Apr 1999 16:05:47 +0000 (16:05 +0000)
* 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
gcc/cp/decl.c
gcc/testsuite/g++.old-deja/g++.pt/crash36.C [new file with mode: 0644]

index 8a85396b40222361203a4cf1834615aee83ac80d..6c64951ac7f140c9f452f52d43685361fbea691b 100644 (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.
index e50c90a22cdba2bc13cb5f19ee84211b8654baee..1ee61fc7c530cbcbeeadbf0779816650df8c3dd0 100644 (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);
 }
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 (file)
index 0000000..b5281c3
--- /dev/null
@@ -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
This page took 0.091718 seconds and 5 git commands to generate.