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 11679


This patch fixes PR 11697, whereby we weren't comparing types
correctly when doing using declarations involving templates.

Tested on i686-pc-linux-gnu, applied on the mainline.

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

2003-08-01  Mark Mitchell  <mark@codesourcery.com>

	PR c++/11697
	* decl.c (decls_match): Don't ignore the types of template
	classes.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1105
diff -c -5 -p -r1.1105 decl.c
*** cp/decl.c	29 Jul 2003 22:15:28 -0000	1.1105
--- cp/decl.c	1 Aug 2003 18:44:45 -0000
*************** decls_match (tree newdecl, tree olddecl)
*** 2756,2775 ****
        else
  	types_match = 0;
      }
    else if (TREE_CODE (newdecl) == TEMPLATE_DECL)
      {
-       if (!comp_template_parms (DECL_TEMPLATE_PARMS (newdecl),
- 				DECL_TEMPLATE_PARMS (olddecl)))
- 	return 0;
- 
        if (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl))
  	  != TREE_CODE (DECL_TEMPLATE_RESULT (olddecl)))
  	return 0;
  
        if (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == TYPE_DECL)
! 	types_match = 1;
        else
  	types_match = decls_match (DECL_TEMPLATE_RESULT (olddecl),
  				   DECL_TEMPLATE_RESULT (newdecl));
      }
    else
--- 2756,2776 ----
        else
  	types_match = 0;
      }
    else if (TREE_CODE (newdecl) == TEMPLATE_DECL)
      {
        if (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl))
  	  != TREE_CODE (DECL_TEMPLATE_RESULT (olddecl)))
  	return 0;
  
+       if (!comp_template_parms (DECL_TEMPLATE_PARMS (newdecl),
+ 				DECL_TEMPLATE_PARMS (olddecl)))
+ 	return 0;
+ 
        if (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == TYPE_DECL)
! 	types_match = same_type_p (TREE_TYPE (DECL_TEMPLATE_RESULT (olddecl)),
! 				   TREE_TYPE (DECL_TEMPLATE_RESULT (newdecl)));
        else
  	types_match = decls_match (DECL_TEMPLATE_RESULT (olddecl),
  				   DECL_TEMPLATE_RESULT (newdecl));
      }
    else
Index: testsuite/g++.dg/template/using6.C
===================================================================
RCS file: testsuite/g++.dg/template/using6.C
diff -N testsuite/g++.dg/template/using6.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/using6.C	1 Aug 2003 18:44:54 -0000
***************
*** 0 ****
--- 1,14 ----
+ namespace foo {
+   template<typename T>
+   struct A {};
+ }
+ 
+ namespace bar {
+   template<typename T>
+   struct A {};
+ }
+ 
+ namespace foo {
+   using bar::A; // { dg-error "" }
+ }
+ 


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