This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix 2726
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH]: Fix 2726
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Tue, 05 Jun 2001 13:55:39 +0100
- Organization: Codesourcery LLC
Hi,
I've installed this on both branch and mainline. It fixes regression
2726, where we ICE'd trying to say something about confusing conversions.
booted & tested on i686-pc-linux-gnu, approved by Mark.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-06-05 Nathan Sidwell <nathan@codesourcery.com>
* call.c (build_user_type_conversion_1): Set ICS_USER_FLAG and
ICS_BAD_FLAG on created conversion.
(compare_ics): Break out rank.
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/call.c,v
retrieving revision 1.269
diff -c -3 -p -r1.269 call.c
*** call.c 2001/05/02 14:38:29 1.269
--- call.c 2001/05/08 15:47:09
*************** build_user_type_conversion_1 (totype, ex
*** 2521,2529 ****
(DECL_CONSTRUCTOR_P (cand->fn)
? totype : non_reference (TREE_TYPE (TREE_TYPE (cand->fn)))),
expr, build_ptr_wrapper (cand));
! ICS_USER_FLAG (cand->second_conv) = 1;
if (cand->viable == -1)
! ICS_BAD_FLAG (cand->second_conv) = 1;
return cand;
}
--- 2521,2530 ----
(DECL_CONSTRUCTOR_P (cand->fn)
? totype : non_reference (TREE_TYPE (TREE_TYPE (cand->fn)))),
expr, build_ptr_wrapper (cand));
!
! ICS_USER_FLAG (cand->second_conv) = ICS_USER_FLAG (*p) = 1;
if (cand->viable == -1)
! ICS_BAD_FLAG (cand->second_conv) = ICS_BAD_FLAG (*p) = 1;
return cand;
}
*************** compare_ics (ics1, ics2)
*** 4772,4777 ****
--- 4773,4779 ----
tree deref_from_type2 = NULL_TREE;
tree deref_to_type1 = NULL_TREE;
tree deref_to_type2 = NULL_TREE;
+ int rank1, rank2;
/* REF_BINDING is non-zero if the result of the conversion sequence
is a reference type. In that case TARGET_TYPE is the
*************** compare_ics (ics1, ics2)
*** 4801,4813 ****
--a user-defined conversion sequence (_over.ics.user_) is a
better conversion sequence than an ellipsis conversion sequence
(_over.ics.ellipsis_). */
! if (ICS_RANK (ics1) > ICS_RANK (ics2))
return -1;
! else if (ICS_RANK (ics1) < ICS_RANK (ics2))
return 1;
! if (ICS_RANK (ics1) == BAD_RANK)
{
/* Both ICS are bad. We try to make a decision based on what
would have happenned if they'd been good. */
if (ICS_USER_FLAG (ics1) > ICS_USER_FLAG (ics2)
--- 4803,4819 ----
--a user-defined conversion sequence (_over.ics.user_) is a
better conversion sequence than an ellipsis conversion sequence
(_over.ics.ellipsis_). */
! rank1 = ICS_RANK (ics1);
! rank2 = ICS_RANK (ics2);
!
! if (rank1 > rank2)
return -1;
! else if (rank1 < rank2)
return 1;
! if (rank1 == BAD_RANK)
{
+ /* XXX Isn't this an extension? */
/* Both ICS are bad. We try to make a decision based on what
would have happenned if they'd been good. */
if (ICS_USER_FLAG (ics1) > ICS_USER_FLAG (ics2)
// Build don't link:
//
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 5 May 2001 <nathan@codesourcery.com>
// Bug 2726. We ICE'd trying to say something about possibly confusing
// conversion overload resolution.
class foo
{
};
template<class T>
class bar
{
public:
operator const T&() const ;
operator T&() ;
};
template<class T, class Ref, class NodePtr, class ListPtr>
class iterator_template
{
public:
iterator_template();
Ref operator*() const;
};
struct IdlDeclarator
{
};
typedef bar< IdlDeclarator > IdlDeclarator_bar;
int
yyparse()
{
iterator_template<IdlDeclarator_bar,IdlDeclarator_bar&,foo*,foo*> declIter;
const IdlDeclarator& declarator = *declIter; // WARNING - choosing
return 1;
}