Displaying 2 results from an estimated 2 matches for "handleconstructorattr".
2020 Oct 30
3
Questions about ctor/dtor attribute related diagnostics
Hi,
I noticed that there are some diagnostics discrepancies between clang and
gcc related to `__attribute__((constructor(n)))` and
`__attribute__((destructor(n)))`.
*[clang]*
It seems priorities >65535 and <0 on ctor/dtor functions are ignored and
are set back to default 65535 in clang and Clang only gives an error when >
32-bit unsigned value specified.
*[g++]*
g++ gives an error for
2020 Nov 05
0
Questions about ctor/dtor attribute related diagnostics
....
>
> [g++]
> g++ gives an error for any values <0 and >65535.
>
> I am wondering should we let Clang's diagnostics match g++ to make things clearer to the user? Or why Clang emits an error for >32-bit unsigned value only?
The code for this lives in SemaDeclAttr.cpp in
`handleConstructorAttr()` and `handleDestructorAttr()`, both of which
are defined similarly as trying to read the attribute argument as an
unsigned 32-bit value. If the value is outside of the range of a
32-bit unsigned number, the `checkUInt32Argument()` helper function
will diagnose it as an error. We don't have an...