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]

Re: A warning option for confusing overload resolution


>>>>> Tobias Ringstrom <tori@prosolvia.se> writes:

> The enclosed patch defines a new warning option (-Woverload-sequence) for
> warnings such as the following.
> qstring.h:340: warning: choosing `QString::operator const char *() const' over
>                `QArrayT<char>::operator const char *<char>() const'
> qstring.h:340: warning:   for conversion from `const QString' to `const char *'
> qstring.h:340: warning:   because conversion sequence for the argument is better

> I chose to disable the warning by default and not to include it in -Wall.

No, I think the better choice is to fix the warning to not be so stupid.
Does this do the trick for you?

1998-07-14  Jason Merrill  <jason@yorick.cygnus.com>

	* call.c (joust): Don't warn about "confusing" conversions to the
	same type.

Index: call.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/call.c,v
retrieving revision 1.92
diff -c -p -r1.92 call.c
*** call.c	1998/06/23 01:48:58	1.92
--- call.c	1998/07/14 11:03:03
*************** joust (cand1, cand2, warn)
*** 4314,4323 ****
  	}
      }
  
!   /* warn about confusing overload resolution */
    if (winner && cand1->second_conv
!       && (! DECL_CONSTRUCTOR_P (cand1->fn)
! 	  || ! DECL_CONSTRUCTOR_P (cand2->fn)))
      {
        int comp = compare_ics (cand1->second_conv, cand2->second_conv);
        if (comp != winner)
--- 4314,4329 ----
  	}
      }
  
!   /* warn about confusing overload resolution for user-defined conversions,
!      either between a constructor and a conversion op, or between two
!      conversion ops.  */
    if (winner && cand1->second_conv
!       && ((DECL_CONSTRUCTOR_P (cand1->fn)
! 	   != DECL_CONSTRUCTOR_P (cand2->fn))
! 	  /* Don't warn if the two conv ops convert to the same type...  */
! 	  || (! DECL_CONSTRUCTOR_P (cand1->fn)
! 	      && ! comptypes (TREE_TYPE (cand1->second_conv),
! 			      TREE_TYPE (cand2->second_conv), 1))))
      {
        int comp = compare_ics (cand1->second_conv, cand2->second_conv);
        if (comp != winner)


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