[cfe-commits] r58357 - in /cfe/trunk: lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaOverload.cpp lib/Sema/SemaOverload.h test/SemaCXX/overload-call.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Wed Oct 29 12:52:12 PDT 2008


Douglas Gregor wrote:
> Author: dgregor
> Date: Tue Oct 28 21:00:59 2008
> New Revision: 58357
>
> URL: http://llvm.org/viewvc/llvm-project?rev=58357&view=rev
> Log:
> Tweak Sema::CheckReferenceInit so that it (optionally) computes an 
> ImplicitConversionSequence and, when doing so, following the specific
> rules of [over.best.ics]. 
>
> The computation of the implicit conversion sequences implements C++
> [over.ics.ref], but we do not (yet) have ranking for implicit
> conversion sequences that use reference binding.
>
>
> @@ -731,17 +733,27 @@
>  /// list), and DeclType is the type of the declaration. When Complain
>  /// is true, this routine will produce diagnostics (and return true)
>  /// when the declaration cannot be initialized with the given
> -/// initializer. When Complain is false, this routine will return true
> -/// when the initialization cannot be performed, but will not produce
> -/// any diagnostics or alter Init.
> -bool Sema::CheckReferenceInit(Expr *&Init, QualType &DeclType, bool Complain) {
> +/// initializer. When ICS is non-null, this routine will compute the
> +/// implicit conversion sequence according to C++ [over.ics.ref] and
> +/// will not produce any diagnostics; when ICS is null, it will emit
> +/// diagnostics when any errors are found.
> +bool 
> +Sema::CheckReferenceInit(Expr *&Init, QualType &DeclType, 
> +                         ImplicitConversionSequence *ICS) {
>   
Am I the only one for whom this is corrupted even after a clean 
checkout? Also, the comment could be a bit more explicit on the meaning 
of the return value. I personally find returning true on error 
counter-intuitive.
> +    if (ICS) {
> +      // C++ [over.ics.ref]p1:
> +      //   When a parameter of reference type binds directly (8.5.3)
> +      //   to an argument expression, the implicit conversion sequence
> +      //   is the identity conversion, unless the argument expression
> +      //   has a type that is a derived class of the parameter type,
> +      //   in which case the implicit conversion sequence is a
> +      //   derived-to-base Conversion (13.3.3.1).
> +      ICS->ConversionKind = ImplicitConversionSequence::StandardConversion;
> +      ICS->Standard.First = ICK_Identity;
> +      ICS->Standard.Second = DerivedToBase? ICK_Derived_To_Base : ICK_Identity;
> +      ICS->Standard.Third = ICK_Identity;
> +      ICS->Standard.FromTypePtr = T2.getAsOpaquePtr();
> +      ICS->Standard.ToTypePtr = T1.getAsOpaquePtr();
> +      ICS->ReferenceBinding = true;
> +      ICS->DirectBinding = true;
>   
What about qualification? Isn't this recorded in the sequence? I would 
have thought that a function can be overloaded on T& vs const T&, so 
whether the argument is const or non-const would be needed for resolution.
Or am I overlooking something terribly obvious?

Sebastian



More information about the cfe-commits mailing list