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] Handle ptmf default conversions while matching a template argument (fix PR/10126)


Hello,

while trying to convert a pointer to member function to match a template
argument (in convert_nontype_argument), we call instantiate_type on the
ADDR_EXPR to check if it matches the template parameter type. The code was
assuming that the instantiated type (if any) would have had to match exactly,
but standard conversions can happen on the way, and we should treat them as a
failure in the match (they're not allowed in this context), rather than abort.
This fixes c++/10126, and its duplicate c++/13040.

I'm not totally sure it's the proper fix, but I thought I submit it anyway.
Bootstrapped (c, c++, java) and tested with no regression on
powerpc-apple-darwin7.0.0 (by Andrew Pinski, many thanks to him).


2003-11-19  Giovanni Bajo  <giovannibajo@libero.it>

        PR c++/10126
        * pt.c (convert_nontype_argument): Handle default conversions
        while converting a pointer to member function.

2003-11-19  Giovanni Bajo  <giovannibajo@libero.it>

        PR c++/10126
        * g++.dg/lookup/ptrmem8.c: New test.


Index: pt.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.788
diff -c -p -r1.788 pt.c
*** pt.c        18 Oct 2003 17:35:46 -0000      1.788
--- pt.c        19 Nov 2003 17:41:28 -0000
*************** convert_nontype_argument (tree type, tre
*** 3303,3310 ****
        if (expr == error_mark_node)
          return error_mark_node;

!       my_friendly_assert (same_type_p (type, TREE_TYPE (expr)),
!                           0);
        return expr;
        }
        break;
--- 3303,3311 ----
        if (expr == error_mark_node)
          return error_mark_node;

!       if (!same_type_p (type, TREE_TYPE (expr)))
!         return error_mark_node;
!
        return expr;
        }
        break;



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