This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for crash
- To: egcs-patches at cygnus dot com
- Subject: C++ PATCH for crash
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Fri, 9 Apr 1999 16:06:46 -0700
- Reply-to: mark at codesourcery dot com
It's not nice to crash, even on incorrect code.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
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.
Index: testsuite/g++.old-deja/g++.pt/crash36.C
===================================================================
RCS file: crash36.C
diff -N crash36.C
*** /dev/null Sat Dec 5 20:30:03 1998
--- crash36.C Fri Apr 9 15:59:49 1999
***************
*** 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
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.335
diff -c -p -r1.335 decl.c
*** decl.c 1999/04/05 23:09:51 1.335
--- decl.c 1999/04/09 23:00:03
*************** make_typename_type (context, name)
*** 5373,5378 ****
--- 5373,5387 ----
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);
}