[Patch] Add the __wchar_t type in MS-compatibility mode (PR15815)

Hans Wennborg hans at chromium.org
Fri May 10 07:18:45 PDT 2013


On Thu, May 9, 2013 at 7:18 PM, Hans Wennborg <hans at chromium.org> wrote:
> On Thu, May 9, 2013 at 6:24 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>>> > What's the change in SemaInit.cpp for? It looks like it's a diagnostic
>>> > improvement for the case where you try to initialize an array of
>>> > character
>>> > type from a string literal of an incompatible type. If this is
>>> > desirable,
>>> > could it be committed separately? Also, should it be using IsStringInit
>>> > rather than isa<StringLiteral>? Right now, it seems to be missing a
>>> > check
>>> > for ObjCEncodeExpr.
>>>
>>> It was for this case in C:
>>>
>>>   __wchar_t s[] = L"foo";
>>>
>>> Where Clang would say: "array initializer must be an initializer list
>>> or string literal" which was weird when the right hand side is already
>>> a string literal. I think we can work on this diagnostic in a separate
>>> patch; for example, we get the same diagnostic for this: char s[] =
>>> L"foo"
>>
>>
>> I think there are two separate issues here. One is that our diagnostic for
>> initializing a character array from a string literal of the wrong type is
>> poor. The other is that, in C, we should not treat __wchar_t as a character
>> type for the purpose of this check (because it can never be initialized by a
>> string literal).
>
> I agree. I have started looking at this in a separate patch.
>
>>> Attaching a new patch. I've changed most uses of WCharTy to
>>> WideCharTy, but I have marked some cases with XXX where I wasn't
>>> completely sure. It would be great if you could double check those.
>>
>>
>> CGRTTI.cpp: This should be WCharTy (note that unsigned int and unsigned char
>> are also in the list).
>> ASTReader: Correct, use WCharTy here (see ASTCommon.cpp for the
>> corresponding serialization code).
>> SemaOverload.cpp: This should be WCharTy (note that unsigned int and
>> unsigned char are also in the list).
>
> I've updated these, and unless there are any other issues I will
> commit tomorrow morning when I have time to watch the buildbots.

Committed in r181587.

Thanks,
Hans



More information about the cfe-commits mailing list