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] |
2008/8/8 Mark Mitchell <mark@codesourcery.com>: > Manuel López-Ibáñez wrote: > >> We do but we warn, so would you rather get two warnings? > > I think it would be good to have your new warning for things like: > > enum X { A }; > X x; > x = 10; > > The "invalid conversion" warning is useful, but that just tells the user > "this program isn't ISO C++, but I'm compiling it anyhow". Your new warning > says "and the answer probably isn't going to be what you expect". > Especially since some early C++ compilers would have made "X" be an "int" > (as in C), legacy code compiled with -fpermissive might have problems like > this. > > So, I think it would be better if you could put your check into the generic > conversion code. Presumably, it could be done at the point that the > compiler actually converts "10" to "X". > Updated patch. Bootstrapped and regression tested on x86_64-pc-linux-gnu wit --enable-languages=all. OK for trunk? 2008-08-09 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR 12242 cp/ * cvt.c (ocp_convert): Warn for out-of-range conversions to enum. testsuite/ * g++.dg/warn/pr12242.C: New.
Attachment:
fix-pr12242-try2.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |