Hi,
this issue was primarily about a bogus warning for line 9 of the
original testcase (the line 'ic < 5u;') which it's already fixed in 4.8.
While reassessing it, I noticed that the location for the genuine
warning, which should point to the '<' operator, is off two chars to the
right: that can be easily fixed by propagating loc from build_new_op_1
to cp_build_binary_op. Note, I have to adjust an existing testcase: I
think it was incorrect to refer to the macro for the -Wdouble-promotion
warning about the implicit conversion in the binary expression: the
issue doesn't happen when the macro is expanded, but later for the '+'
in 'cf + 1.0 * ID'.
Tested x86_64-linux.
Thanks!
Paolo.
//////////////////////////
/cp
2013-05-20 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/23608
* call.c (build_new_op_1): Propagate loc to cp_build_binary_op.
/testsuite
2013-05-20 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/23608
* g++.dg/warn/Wsign-compare-6.C: New.
* g++.dg/warn/Wdouble-promotion.C: Adjust.
Index: cp/call.c
===================================================================
--- cp/call.c (revision 199093)
+++ cp/call.c (working copy)
@@ -5418,7 +5418,7 @@ build_new_op_1 (location_t loc, enum tree_code cod
case BIT_AND_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
- return cp_build_binary_op (input_location, code, arg1, arg2, complain);
+ return cp_build_binary_op (loc, code, arg1, arg2, complain);
case UNARY_PLUS_EXPR:
case NEGATE_EXPR:
Index: testsuite/g++.dg/warn/Wdouble-promotion.C
===================================================================
--- testsuite/g++.dg/warn/Wdouble-promotion.C (revision 199093)
+++ testsuite/g++.dg/warn/Wdouble-promotion.C (working copy)
@@ -5,7 +5,7 @@
/* Some targets do not provide <complex.h> so we define I ourselves. */
#define I 1.0iF
-#define ID ((_Complex double)I) // { dg-warning "implicit" }
+#define ID ((_Complex double)I)
float f;
double d;
@@ -36,7 +36,7 @@ usual_arithmetic_conversions(void)
local_cf = cf + 1.0; /* { dg-warning "implicit" } */
local_cf = cf - d; /* { dg-warning "implicit" } */
- local_cf = cf + 1.0 * ID; /* { dg-message "in expansion of macro 'ID'" } */
+ local_cf = cf + 1.0 * ID; /* { dg-warning "implicit" } */
local_cf = cf - cd; /* { dg-warning "implicit" } */
local_f = i ? f : d; /* { dg-warning "implicit" } */
Index: testsuite/g++.dg/warn/Wsign-compare-6.C
===================================================================
--- testsuite/g++.dg/warn/Wsign-compare-6.C (revision 0)
+++ testsuite/g++.dg/warn/Wsign-compare-6.C (working copy)
@@ -0,0 +1,14 @@
+// PR c++/23608
+// { dg-options "-Wsign-compare" }
+
+#define FIVE 5
+
+int main()
+{
+ int i = 5;
+ int const ic = 5;
+
+ i < 5u; // { dg-warning "5:comparison between signed and unsigned" }
+ ic < 5u;
+ FIVE < 5u;
+}