[cfe-dev] -Warray-bounds seems over-zealous on Clang

Nicola Gigante nicola.gigante at gmail.com
Wed Jul 13 13:10:59 PDT 2011

Il giorno 13/lug/2011, alle ore 17.49, Ted Kremenek ha scritto:

> On Jul 13, 2011, at 8:05 AM, David Blaikie wrote:
>> So, options that seem to be being discussed include:
>> 1) suppress this warning in all cases where the array is of length 1 and the last element in a struct
>>   1.1) refinement: only when the length is specified explicitly and not via macro expansion, etc. (as John suggested)
>>   1.2) refinement: under c99 recommend a fixup to use flexible arrays
>> 2) split the warning in two, the second being the cases suppressed by the above option (probably less interesting if 1.1 is implemented)
> (1) and (2) aren't mutually exclusive.  (2) is still useful when the heuristics implied by 1.1 and 1.2 aren't good enough.

I've tried to write such a patch, as it seemed simple, but I'm stuck because I don't know enough
about internal clang's APIs yet.
Until now, I've come up with the simple patch attached, that disables the warning if
the array is declared inside a record type and the size is one.
- From the NamedDecl* object representing the array declaration, how do I know if it's declared last in the struct?
- From the NamedDecl*, how do I know if the size of the member declaration comes from a macro expansion?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110713/eed6b8b5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgsql_warning.patch
Type: application/octet-stream
Size: 698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110713/eed6b8b5/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110713/eed6b8b5/attachment-0001.html>

More information about the cfe-dev mailing list