Description
This issue appeared after pull request: #136855
I have noticed excessive reporting with constant NULL pointer for the new C++ compatibly warnings implemented in 15321d2.
Please see the following code:
__attribute__((address_space(0))) char *b;
__attribute__((address_space(21))) char *c;
int main(int argc, char *argv[])
{
c = (__attribute__((address_space(21))) void*)0x25;
b = (__attribute__((address_space(0))) void*)0;
return (c > 0) & (b != 0);
}
When compiled with following line:
clang -target amdgcn -Wimplicit-void-ptr-cast /testcode/llvm-clean/test.c -o a.out
The following warnings are produced:
/testcode/llvm-clean/test.c:11:7: warning: implicit conversion when assigning to '__attribute__((address_space(21))) char *' from type '__attribute__((address_space(21))) void *' is not permitted in C++ [-Wimplicit-void-ptr-cast]
11 | c = (__attribute__((address_space(21))) void*)0x25;
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/testcode/llvm-clean/test.c:13:7: warning: implicit conversion when assigning to '__attribute__((address_space(0))) char *' from type '__attribute__((address_space(0))) void *' is not permitted in C++ [-Wimplicit-void-ptr-cast]
13 | b = (__attribute__((address_space(0))) void*)0;
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
However when i compile slightly different code:
__attribute__((address_space(0))) char *b;
__attribute__((address_space(21))) char *c;
int main(int argc, char *argv[])
{
c = (__attribute__((address_space(21))) void*)0x25;
b = (void*)0;
return (c > 0) & (b != 0);
}
or
char *b;
__attribute__((address_space(21))) char *c;
int main(int argc, char *argv[])
{
c = (__attribute__((address_space(21))) void*)0x25;
b = (void*)0;
return (c > 0) & (b != 0);
}
no warnings regarding assignment of variable b
are generated.
Please note in C++ mode all 3 assignments are invalid and thus should be generating the exactly same diagnostics.
Please also note the behavior for non-null constant c
is consistent.
I believe this issue should be addressed in the way either NULL assignment never generate a warning or always generate a warning. After some deliberations i believe it should always generate a warning meaning cases 2&3 returning insufficient diagnostics.
PS: Sorry for not giving godbolt examples but godbolt does not seems support amdgcn target :(
PPS: All testing initially was done with 74593f6