This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C/C++ Patch] PR 51294
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>, Jason Merrill <jason at redhat dot com>
- Date: Sat, 12 May 2012 19:51:04 +0200
- Subject: Re: [C/C++ Patch] PR 51294
- References: <4FAE9F38.9030400@oracle.com>
On 12 May 2012 19:34, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> the below is my (very conservative, I think) interpretation of what we
> recently summarized we want to do wrt these -Wconversion warnings in the
> conditional expressions context. Of course many details could be different,
> please let me know... This is booted and tested on x86_64-linux.
>
> Thanks,
> Paolo.
It seems very conservative also to me. I think the code should just
unconditionally recurse on the operands of COND_EXPR. The recursion
should then take care of the casts. So then c = b ? c : i; will warn
about 'i', not about the whole conditional expression.
Did you find any issues with doing:
+ STRIP_USELESS_TYPE_CONVERSION (expr);
+ /* Don't warn about unsigned char y = 0xff, x = (int) y; */
+ expr = get_unwidened (expr, 0);
+ expr_type = TREE_TYPE (expr);
just before the switch? (and deleting the get_unwidened quite a few
lines below)
Cheers,
Manuel.