Re: [C++ Patch] Avoid duplicate warning

2019-11-19 Thread Jason Merrill

On 11/18/19 3:45 PM, Paolo Carlini wrote:

functions like c_common_truthvalue_conversion are shared with the C 
front-end thus don't get a tsubst_flags_t argument. It seems clear that 
long term we have to do something about those but in the meanwhile we 
have been using warning sentinels which, along the paths which certainly 
must have all the warnings suppressed, work well for now and cannot 
cause regressions. Here I propose to add (at least) one more to 
ocp_convert since I have a straightforward testcase.


OK.


Note sue if we want to proactively add, say, one for warn_parentheses too.


Not without a testcase.

Jason



[C++ Patch] Avoid duplicate warning

2019-11-18 Thread Paolo Carlini

Hi,

functions like c_common_truthvalue_conversion are shared with the C 
front-end thus don't get a tsubst_flags_t argument. It seems clear that 
long term we have to do something about those but in the meanwhile we 
have been using warning sentinels which, along the paths which certainly 
must have all the warnings suppressed, work well for now and cannot 
cause regressions. Here I propose to add (at least) one more to 
ocp_convert since I have a straightforward testcase. Note sue if we want 
to proactively add, say, one for warn_parentheses too.


Tested x86_64-linux.

Thanks, Paolo.

///

/cp
2019-11-18  Paolo Carlini  

* cvt.c (ocp_convert): Use additional warning sentinel.

/testsuite
2019-11-18  Paolo Carlini  

* g++.dg/warn/multiple-sign-compare-warn-1.C: New.
Index: cp/cvt.c
===
--- cp/cvt.c(revision 278407)
+++ cp/cvt.c(working copy)
@@ -847,6 +847,7 @@ ocp_convert (tree type, tree expr, int convtype, i
  /* Prevent bogus -Wint-in-bool-context warnings coming
 from c_common_truthvalue_conversion down the line.  */
  warning_sentinel w (warn_int_in_bool_context);
+ warning_sentinel c (warn_sign_compare);
  return cp_truthvalue_conversion (e, complain);
}
}
Index: testsuite/g++.dg/warn/multiple-sign-compare-warn-1.C
===
--- testsuite/g++.dg/warn/multiple-sign-compare-warn-1.C(nonexistent)
+++ testsuite/g++.dg/warn/multiple-sign-compare-warn-1.C(working copy)
@@ -0,0 +1,11 @@
+// { dg-options "-Wsign-compare" }
+
+int foo()
+{
+  unsigned char b = '1';
+
+  bool x = ~b; // { dg-bogus "promoted bitwise complement of an unsigned value 
is always nonzero.*promoted bitwise complement of an unsigned value is always 
nonzero" }
+ // { dg-warning "promoted bitwise complement of an unsigned value is always 
nonzero" "" { target *-*-* } .-1 }
+
+  return 0;
+}