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 c++/8906


This patch fixes PR 8906, a regression in 3.3.  This is already fixed
in 3.4 due to the new parser, but here's the 3.3 fix.

Tested on i686-pc-linux-gnu, applied on the branch.  The test case
will also go on the mainline.

--
Mark Mitchell                   mark at codesourcery dot com
CodeSourcery, LLC               http://www.codesourcery.com

2003-02-21  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/8906
	* decl.c (lookup_name_real): Use IMPLICIT_TYPENAME_P.
	* decl2.c (handle_class_head): Check it.

2003-02-21  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/8906
	* g++.dg/template/nested2.C: New test.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.965.2.13
diff -c -5 -p -r1.965.2.13 decl.c
*** cp/decl.c	18 Feb 2003 18:53:21 -0000	1.965.2.13
--- cp/decl.c	21 Feb 2003 20:09:51 -0000
*************** lookup_name_real (name, prefer_type, non
*** 6155,6165 ****
  
        if (type)
  	{
  	  if (type == error_mark_node)
  	    POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
! 	  if (TREE_CODE (type) == TYPENAME_TYPE && TREE_TYPE (type))
  	    type = TREE_TYPE (type);
  
  	  if (TYPE_P (type))
  	    type = complete_type (type);
  
--- 6155,6165 ----
  
        if (type)
  	{
  	  if (type == error_mark_node)
  	    POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
! 	  if (IMPLICIT_TYPENAME_P (type))
  	    type = TREE_TYPE (type);
  
  	  if (TYPE_P (type))
  	    type = complete_type (type);
  
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.575.2.7
diff -c -5 -p -r1.575.2.7 decl2.c
*** cp/decl2.c	13 Feb 2003 07:17:10 -0000	1.575.2.7
--- cp/decl2.c	21 Feb 2003 20:09:52 -0000
*************** handle_class_head (tag_kind, scope, id, 
*** 4890,4899 ****
--- 4890,4902 ----
        /* For a definition, we want to enter the containing scope
  	 before looking up any base classes etc. Only do so, if this
  	 is different to the current scope.  */
        tree context = CP_DECL_CONTEXT (decl);
  
+       if (IMPLICIT_TYPENAME_P (context))
+ 	context = TREE_TYPE (context);
+ 
        *new_type_p = (current != context
  		     && TREE_CODE (context) != TEMPLATE_TYPE_PARM
  		     && TREE_CODE (context) != BOUND_TEMPLATE_TEMPLATE_PARM);
        if (*new_type_p)
  	push_scope (context);
Index: testsuite/g++.dg/template/nested2.C
===================================================================
RCS file: testsuite/g++.dg/template/nested2.C
diff -N testsuite/g++.dg/template/nested2.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/nested2.C	21 Feb 2003 20:09:52 -0000
***************
*** 0 ****
--- 1,9 ----
+ template <class T> class CO {
+     class CI1 {
+ 	class CI2;
+     };
+ };
+ 
+ template <class T>
+ class CO<T>::CI1::CI2 {};
+ 


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