We're currently using address spaces to implement ptr32/ptr64 attributes;
this patch fixes a bug where clang doesn't allow types with different pointer
size attributes to be compared.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Sema/SemaExprCXX.cpp | ||
---|---|---|
6682 | I'm pretty sure this is correct based on my inspection of what code MSVC is generating. But it would be helpful to have some codegen tests in Clang for this functionality as well. | |
clang/test/Sema/MicrosoftExtensions.cpp | ||
10–11 | (Side question, not directly about this patch but sorta related.) Should there be a diagnostic about conversion potentially causing a possible loss of data (on the 64-bit target)? |
clang/lib/Sema/SemaExprCXX.cpp | ||
---|---|---|
6682 | ha, I apparently didn't check that the behavior actually matches.. apparently in MSVC a ptr32 isn't equivalent to a ptr64 |
clang/lib/Sema/SemaExprCXX.cpp | ||
---|---|---|
6682 | Oh! I had tested this: int test1(int * __ptr32 __uptr p32u, int * __ptr32 __sptr p32s, int * __ptr64 p64) { return (p32u == p64); } int test2(int * __ptr32 __uptr p32u, int * __ptr32 __sptr p32s, int * __ptr64 p64) { return (p64 == p32u); } to see whether the order of the operands mattered as to which conversion "won" and I thought I saw that your patch generates the same code that MSVC does. However, I could have messed my testing up somehow, so double-checking is a good idea. |
clang/lib/Sema/SemaExprCXX.cpp | ||
---|---|---|
6682 | Whoops, you're right, I was not specifying sptr/uptr and I guess clang and msvc have different defaults for sign/zero extension. Will add tests. Also, thanks for reviewing! | |
clang/test/Sema/MicrosoftExtensions.cpp | ||
10–11 | Hmm, it seems reasonable, but I also don't know how motivated I am to add a diagnostic -- |
clang/test/Sema/MicrosoftExtensions.cpp | ||
---|---|---|
10–11 | I don't insist -- we are missing that warning in general here (we don't warn on assignment yet). But it might be a nice follow-up for anyone who's interested in working on it. |
I'm pretty sure this is correct based on my inspection of what code MSVC is generating. But it would be helpful to have some codegen tests in Clang for this functionality as well.