Hi,
On 07/18/2012 02:40 PM, Jakub Jelinek wrote:
The problem on the GCC side is that both the C and C++ FEs fold away the
sizeof too early (well, C++ FE only when not in a template, otherwise
SIZEOF_EXPR is created and guess one could tsubst its argument again).
I've only done C FE right now, instead of constructing SIZEOF_EXPR always
and folding it later on (which would be much more work and could risk
regressions) I'm just remembering the last sizeof argument which is all that
is needed for this kind of warning (yeah, admit not very nice, but works).
For C++ I guess similar spot could be finish_call_expr (adding another
argument, usually NULL, to it) that would be feeded by remembered last sizeof
argument or during tsubst from SIZEOF_EXPR argument after tsubsting.
I have a couple of random comments. About the folding, I'm wondering if
our current behavior is causing actual bugs (similarly to, eg, all the
issues we have with arrays decaying to pointers too early). Otherwise,
the implementation of the warning itself seems to me a little ad hoc
indeed, but simple enough.
Unrelated, but I can't resist, it would be great if for 4.8 we could
also eliminate the duplicate diagnostics noticed in 28656, does that
look doable?!? If you have hints I could also do it, in practice.
Thanks!
Paolo.