[cfe-commits] r91767 - in /cfe/trunk: lib/Sema/ test/CXX/class/class.local/ test/CXX/dcl.decl/dcl.meaning/dcl.mptr/ test/CXX/over/over.over/ test/Sema/ test/SemaCXX/ test/SemaObjCXX/ test/SemaTemplate/

Eli Friedman eli.friedman at gmail.com
Sun Dec 20 14:18:53 PST 2009


On Sun, Dec 20, 2009 at 1:07 PM, Douglas Gregor <dgregor at apple.com> wrote:
>
> On Dec 19, 2009, at 12:11 AM, Eli Friedman wrote:
>
> Author: efriedma
> Date: Sat Dec 19 02:11:05 2009
> New Revision: 91767
>
> URL: http://llvm.org/viewvc/llvm-project?rev=91767&view=rev
> Log:
> Initialization improvements: addition of string initialization and a few
> small bug fixes in SemaInit, switch over SemaDecl to use it more often, and
> change a bunch of diagnostics which are different with the new
> initialization
> code.
>
> Cool, thanks! Comments below...
>
> @@ -2492,7 +2500,8 @@
>                                            const InitializationKind &Kind,
>                                            Expr *Initializer,
>                                        InitializationSequence &Sequence) {
> -  // FIXME: Implement!
> +  Sequence.setSequenceKind(InitializationSequence::StringInit);
> +  Sequence.AddStringInitStep(Entity.getType().getType());
> }
>
> We'll need to perform more of the checking from CheckStringInit here, to
> determine whether it is valid to initialize the entity with the given string
> literal. That will become important when overload resolution switches over
> to using InitializationSequences, because we determine the validity of the
> initialization in the "Try*" function and then actually perform the
> initialization in "Perform".

Umm, I'm not sure what exactly you want me to do here:

1. CheckStringInit doesn't do anything relevant; all the interesting
logic is in IsStringInit, which we already call.
2. It's impossible to end up in TryStringLiteralInitialization in
overload resolution because a function can't take an array as a
argument.

> /// \brief Attempt initialization by constructor (C++ [dcl.init]), which
> @@ -2711,10 +2720,17 @@
>       }
>     }
>   }
> -
> +
> +  SourceLocation DeclLoc = Initializer->getLocStart();
> +
>   if (const RecordType *SourceRecordType = SourceType->getAs<RecordType>())
> {
>     // The type we're converting from is a class type, enumerate its
> conversion
>     // functions.
> +
> +    // Try to force the type to be complete before enumerating the
> conversion
> +    // functions; it's okay if this fails, though.
> +    S.RequireCompleteType(DeclLoc, SourceType, 0);
>
> This would be better as
> if (!S.RequireCompleteType(DeclLoc, SourceType, 0)) {
> // enumerate conversion functions
> }

Done in r91797.

-Eli




More information about the cfe-commits mailing list