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] Fix PR11154 regression (main trunk version)


This is just the main trunk version of the fix to PR11154.  Same ChangeLog
as patch for 3.3.

--Kriang

diff -cprN gcc-main-save/gcc/cp/cp-tree.h gcc-main-new/gcc/cp/cp-tree.h
*** gcc-main-save/gcc/cp/cp-tree.h	Thu Jul 10 19:51:26 2003
--- gcc-main-new/gcc/cp/cp-tree.h	Fri Jul 11 22:27:21 2003
*************** extern tree instantiate_decl			(tree, in
*** 3952,3958 ****
  extern tree get_bindings			(tree, tree, tree);
  extern int push_tinst_level			(tree);
  extern void pop_tinst_level			(void);
! extern int more_specialized_class		(tree, tree);
  extern int is_member_template                   (tree);
  extern int comp_template_parms                  (tree, tree);
  extern int template_class_depth                 (tree);
--- 3952,3958 ----
  extern tree get_bindings			(tree, tree, tree);
  extern int push_tinst_level			(tree);
  extern void pop_tinst_level			(void);
! extern int more_specialized_class		(tree, tree, tree);
  extern int is_member_template                   (tree);
  extern int comp_template_parms                  (tree, tree);
  extern int template_class_depth                 (tree);
diff -cprN gcc-main-save/gcc/cp/pt.c gcc-main-new/gcc/cp/pt.c
*** gcc-main-save/gcc/cp/pt.c	Thu Jul 10 19:51:27 2003
--- gcc-main-new/gcc/cp/pt.c	Fri Jul 11 22:27:20 2003
*************** more_specialized (tree pat1, tree pat2, 
*** 9964,9984 ****
  
     1 if PAT1 is more specialized than PAT2 as described in [temp.class.order].
     -1 if PAT2 is more specialized than PAT1.
!    0 if neither is more specialized.  */
     
  int
! more_specialized_class (tree pat1, tree pat2)
  {
    tree targs;
    int winner = 0;
  
    targs = get_class_bindings (TREE_VALUE (pat1), TREE_PURPOSE (pat1),
! 			      TREE_PURPOSE (pat2));
    if (targs)
      --winner;
  
    targs = get_class_bindings (TREE_VALUE (pat2), TREE_PURPOSE (pat2),
! 			      TREE_PURPOSE (pat1));
    if (targs)
      ++winner;
  
--- 9964,9987 ----
  
     1 if PAT1 is more specialized than PAT2 as described in [temp.class.order].
     -1 if PAT2 is more specialized than PAT1.
!    0 if neither is more specialized.
! 
!    FULL_ARGS is the full set of template arguments that triggers this
!    partial ordering.  */
     
  int
! more_specialized_class (tree pat1, tree pat2, tree full_args)
  {
    tree targs;
    int winner = 0;
  
    targs = get_class_bindings (TREE_VALUE (pat1), TREE_PURPOSE (pat1),
! 			      add_outermost_template_args (full_args, TREE_PURPOSE (pat2)));
    if (targs)
      --winner;
  
    targs = get_class_bindings (TREE_VALUE (pat2), TREE_PURPOSE (pat2),
! 			      add_outermost_template_args (full_args, TREE_PURPOSE (pat1)));
    if (targs)
      ++winner;
  
*************** most_specialized_class (tree tmpl, tree 
*** 10259,10265 ****
    t = TREE_CHAIN (t);
    for (; t; t = TREE_CHAIN (t))
      {
!       fate = more_specialized_class (champ, t);
        if (fate == 1)
  	;
        else
--- 10262,10268 ----
    t = TREE_CHAIN (t);
    for (; t; t = TREE_CHAIN (t))
      {
!       fate = more_specialized_class (champ, t, args);
        if (fate == 1)
  	;
        else
*************** most_specialized_class (tree tmpl, tree 
*** 10276,10282 ****
  
    for (t = list; t && t != champ; t = TREE_CHAIN (t))
      {
!       fate = more_specialized_class (champ, t);
        if (fate != 1)
  	return error_mark_node;
      }
--- 10279,10285 ----
  
    for (t = list; t && t != champ; t = TREE_CHAIN (t))
      {
!       fate = more_specialized_class (champ, t, args);
        if (fate != 1)
  	return error_mark_node;
      }
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/partial2.C gcc-main-new/gcc/testsuite/g++.dg/template/partial2.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/partial2.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/partial2.C	Fri Jul 11 22:25:35 2003
***************
*** 0 ****
--- 1,14 ----
+ // { dg-do compile }
+ 
+ // Origin: lorgon1@yahoo.com
+ 
+ // PR c++/11154: Multi-level template argument in partial ordering of
+ // class template
+ 
+ template <class A> struct Outer {
+    template <class T, class U = void, class V = void> struct Foo {};
+    template <class T, class U> struct Foo<T,U,void> {};
+    template <class T> struct Foo<T,void,void> {};
+ };
+ 
+ Outer<int>::Foo<int,void,void> f;


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