This is an archive of the discontinued LLVM Phabricator instance.

[AIX] Define WCHAR_T_TYPE as unsigned short on AIX for wchar.c test case.
ClosedPublic

Authored by amyk on Sep 24 2021, 10:04 AM.

Details

Summary

The default wchar type is different on AIX vs. Linux. When this test is run on AIX,
WCHAR_T_TYPE ends up being set to int. This is incorrect as the default
wchar type on AIX is actually unsigned short, and setting the type incorrectly
causes the expected errors to not be found.

This patch sets the type correctly (to unsigned short) for AIX.

Diff Detail

Event Timeline

amyk requested review of this revision.Sep 24 2021, 10:04 AM
amyk created this revision.

This doesn't appear to be true for 64-bit AIX:

extern "C" int printf(const char *, ...);
int main() {
        printf("wchar_t: %ld\nunsigned short: %ld\n",sizeof(wchar_t),sizeof(unsigned short));
        return 0;
}
$ clang++ -m64 foo.cc
$ ./a.out
wchar_t: 4
unsigned short: 2
amyk updated this revision to Diff 376723.Oct 2 2021, 3:28 PM

Addressed comment made by @daltenty.
Update the patch to account set the wchar type to unsigned short only on 32-bit AIX.

daltenty accepted this revision.Oct 5 2021, 2:23 PM
This revision is now accepted and ready to land.Oct 5 2021, 2:23 PM