<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 13, 2011, at 1:21 PM, John McCall wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jul 13, 2011, at 1:10 PM, Nicola Gigante wrote:</div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>Il giorno 13/lug/2011, alle ore 17.49, Ted Kremenek ha scritto:</div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jul 13, 2011, at 8:05 AM, David Blaikie wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">So, options that seem to be being discussed include:<br><br>1) suppress this warning in all cases where the array is of length 1 and the last element in a struct<br>  1.1) refinement: only when the length is specified explicitly and not via macro expansion, etc. (as John suggested)<br>  1.2) refinement: under c99 recommend a fixup to use flexible arrays<br>2) split the warning in two, the second being the cases suppressed by the above option (probably less interesting if 1.1 is implemented)<br> </span></blockquote></div><br><div>(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.</div></div></blockquote><br></div><div>I've tried to write such a patch, as it seemed simple, but I'm stuck because I don't know enough</div><div>about internal clang's APIs yet.</div><div>Until now, I've come up with the simple patch attached, that disables the warning if</div><div>the array is declared inside a record type and the size is one.</div><div>Questions:</div><div>- From the NamedDecl* object representing the array declaration, how do I know if it's declared last in the struct?</div></div></blockquote><div><br></div><div>It should be a FieldDecl, and its parent should be a RecordDecl.  I don't think there's a cleaner solution than just iterating through the fields of the record and complaining if it's not the last one.</div></div></div></blockquote><div><br></div>Oh, of course there's getNextDeclInContext();  you could just walk those (until you get a null pointer back) and make sure there aren't any FieldDecls.</div><div><br></div><div>John.</div></body></html>