This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 5754


This patch fixes a 3.3 ICE-on-invalid regression (already fixed on the
mainline with the new parser).

Tested on i686-pc-linux-gnu, applied on the branch.  I put the test
case on the mainline too.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-06-23  Mark Mitchell  <mark@codesourcery.com>

	PR c++/5754
	* parse.y (structsp): Improve error handling of invalid nested
	template classes.

2003-06-24  Mark Mitchell  <mark@codesourcery.com>

	PR c++/5754
	* g++.dg/parse/crash6.C: New test.

Index: cp/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Attic/parse.y,v
retrieving revision 1.284.2.5
diff -c -5 -p -r1.284.2.5 parse.y
*** cp/parse.y	17 Mar 2003 12:00:26 -0000	1.284.2.5
--- cp/parse.y	24 Jun 2003 07:24:24 -0000
*************** structsp:
*** 2326,2339 ****
  		  if ($2 && $1.t != error_mark_node)
  		    {
  		      tree type = TREE_TYPE ($1.t);
  
  		      if (TREE_CODE (type) == TYPENAME_TYPE)
! 			/* In a definition of a member class template,
!                            we will get here with an implicit typename,
!                            a TYPENAME_TYPE with a type. */
! 			type = TREE_TYPE (type);
  		      maybe_process_partial_specialization (type);
  		      xref_basetypes (type, $2);
  		    }
  		  $1.t = begin_class_definition (TREE_TYPE ($1.t));
  		  check_class_key (current_aggr, $1.t);
--- 2326,2347 ----
  		  if ($2 && $1.t != error_mark_node)
  		    {
  		      tree type = TREE_TYPE ($1.t);
  
  		      if (TREE_CODE (type) == TYPENAME_TYPE)
! 			{
! 			  if (IMPLICIT_TYPENAME_P (type))
! 			    /* In a definition of a member class template,
! 			       we will get here with an implicit typename,
! 			       a TYPENAME_TYPE with a type. */
! 			    type = TREE_TYPE (type);
! 			  else
! 			    {
! 			      error ("qualified name does not name a class");
! 			      type = error_mark_node;
! 			    }
! 			}
  		      maybe_process_partial_specialization (type);
  		      xref_basetypes (type, $2);
  		    }
  		  $1.t = begin_class_definition (TREE_TYPE ($1.t));
  		  check_class_key (current_aggr, $1.t);
Index: testsuite/g++.dg/parse/crash6.C
===================================================================
RCS file: testsuite/g++.dg/parse/crash6.C
diff -N testsuite/g++.dg/parse/crash6.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/crash6.C	24 Jun 2003 07:24:28 -0000
***************
*** 0 ****
--- 1,10 ----
+ struct P {};
+     
+ template <typename >
+ struct O 
+ {
+     struct I;
+ };
+ 
+ template <typename T>
+ struct O<T>::I::S : P {}; // { dg-error "" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]