[Patch] Better diagnostics for string initialization (and fix for C11)

Hans Wennborg hans at chromium.org
Thu May 16 02:24:31 PDT 2013


On Wed, May 15, 2013 at 9:29 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Wed, May 15, 2013 at 4:08 AM, Hans Wennborg <hans at chromium.org> wrote:
>>
>> On Tue, May 14, 2013 at 9:37 PM, Richard Smith <richard at metafoo.co.uk>
>> wrote:
>> > @@ -79,7 +117,7 @@ static Expr *IsStringInit(Expr *init, QualType
>> > declType,
>> > ASTContext &Context) {
>> >    const ArrayType *arrayType = Context.getAsArrayType(declType);
>> >    if (!arrayType) return 0;
>> >
>> > -  return IsStringInit(init, arrayType, Context);
>> > +  return IsStringInit(init, arrayType, Context) == SIF_None ? init : 0;
>> >
>> > Looks like the one and only caller of this doesn't actually want the
>> > expression; maybe just return the SIF value here too?
>>
>> I've changed it to just return bool since that's really what the
>> caller is looking for.
>
> The overload set for IsStringInit is now pretty scary: one overload returns
> zero (as an enum) on success and the other returns true, and the only
> difference in their signatures is that one takes a 'const ArrayType*' where
> the other takes a 'QualType'. Please make them both return the same type.

Good point. Fixed in r181995.

Thanks,
Hans



More information about the cfe-commits mailing list