This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 18/02/2008, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote: > On 18/02/2008, Joseph S. Myers <joseph@codesourcery.com> wrote: > > > > I agree with that in principle - but I also think it's useful to avoid > > warning for such cases as short = (int & 0x7fff) when written directly by > > the user (with any non-negative constant in the range of short there). I > > suppose there are other cases where it may be less likely that the user > > will write the code created by the compiler, but anything affecting > > expressions directly written by the user would still be of some use after > > the front end no longer does the present folding. (This means there > > should be testcases where the problem expressions are written directly by > > the user, not just the tests where they are compiler-generated.) The following patch is a bit cleaner than the previous proposal.It also handles a lot more of cases. In particular, it handles short = (int & 0x7fff). There is an XFAIL because common_types does completely different things in C and C++. I think that is a latent bug exposed by my patch. Let me know your opinions and suggestions. Bootstrapped and regression tested in x86_64-unknown-linux-gnu. Cheers, Manuel. 2008-02-18 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR 34389 * c-typeck.c (build_binary_op): Encapsulate code into... * c-common.c (shorten_binary_op): ...this new function. (conversion_warning): Use the new function. Handle non-negative constant in bitwise-and. * c-common.h (shorten_binary_op): Declare. cp/ * typeck.c (build_binary_op): Encapsulate code into the new function. testsuite/ * gcc.dg/Wconversion-pr34389.c: New. * g++.dg/warn/Wconversion-pr34389.C: New.
Attachment:
fix-pr34389.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |