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] |
"Manuel López-Ibáñez" <lopezibanez@gmail.com> writes:
[...]
| > Make a list of all th without extensively modifying the C and C++ front-ends.e places where the C++ front-end does not call | > convert_and_check (that is already contained in your patch). | | I don't understand this. Do you mean the places where the C++ | front-end calls a conversion function instead of convert_and_check ?
Yes. Essentially, you can trace brack from ocp_convert, with a grep...
For ocp_convert() I have: force_rvalue(), cp_convert(), convert(), convert_force(), initialize_handler_parm(), expand_default_init(), convert_nontype_argument(), build_static_cast_1, convert_for_initialization().
I have looked to those functions and I still don't understand what you want me to do. I tried modifying ocp_convert to add the warnings there and a new argument 'issue_conversion_warnings' as in 'convert_like_real', but the required modifications are too large and intrusive. I really don't know how to implement your suggestion.
As an alternative, I have prepared the following patch. It addresses the concerns about the original patch in two ways. First, it adds a new function cp_convert_and_check, so 1) no need to call convert when we actually want cp_convert, and 2) no result is thrown away.
Secondly, in 'convert_like_real', it uses the already existing call to convert_and_check to detect conversions from floating-point to integer, no additional call to convert_and_check is needed any more. In order for this to work for references, we need to pass the original value of issue_conversion_warnings to subsequent calls to convert_like_real.
It bootstraps and passes all regression tests. Do you see any potential problem with this version?
* doc/invoke.texi (-Wconversion): Document warnings specific to C++. * c-common.c (convert_and_check): Move warning logic to... (warnings_for_convert_and_check): ...here. Define. * c-common.h (warnings_for_convert_and_check): Declare.
cp/ * cvt.c (cp_convert_and_check) : Define. * cp-tree.h (cp_convert_and_check): Declare. * call.c (convert_like_real): Use convert_and_check instead of custom warning. * typeck.c (build_binary_op): Use cp_convert_and_check to warn for overflow and changes of value during conversion.
testsuite/ * g++.dg/warn/Wconversion-integer.C: New * g++.dg/warn/Wconversion-real.C: New. * g++.dg/warn/Wconversion-real-integer.C: New. * g++.dg/warn/conv2.C: Modified.
Attachment:
wcoercion-4-gplusplus-try7.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |