[cfe-dev] [PATCH]: wchar_t foo[] = L"bar"

Eli Friedman eli.friedman at gmail.com
Wed Nov 26 12:23:05 PST 2008


On Wed, Nov 26, 2008 at 8:11 AM, Doug Gregor <doug.gregor at gmail.com> wrote:
> On Fri, Nov 21, 2008 at 9:11 AM, Roman Divacky <rdivacky at freebsd.org> wrote:
> +bool ASTContext::isWideCharType(QualType Ty) const {
> +   return Ty->getCanonicalTypeInternal().getUnqualifiedType() ==
> getWCharType();
> +}
>
> This will always work in C++ (where wchar_t is a distinct type), but
> the fact that it works now in C is due to an error in
> ASTContext::getWCharType, which isn't doing the right thing for C:
>
> QualType ASTContext::getWCharType() const {
>  if (LangOpts.CPlusPlus)
>    return WCharTy;
>
>  // FIXME: In C, shouldn't WCharTy just be a typedef of the target's
>  // wide-character type?
>  return getFromTargetType(Target.getWCharType());
> }
>
> If we fix getWCharType, ASTContext::isWideCharType will no longer
> work, since getWCharType would then return a typedef.

So then, the implementation has to change to "return
Ty->getCanonicalTypeInternal().getUnqualifiedType() ==
getWCharType().getCanonicalType();"?  That doesn't seem like a serious
issue.

-Eli



More information about the cfe-dev mailing list