gcc/c/
PR c/109827
PR other/44209
* c-typeck.cc (build_conditional_expr): Use OPT_Wint_conversion
for pointer/integer mismatch warnings.
gcc/testsuite/
* gcc.dg/Wint-conversion-3.c: New.
&& (code2 == INTEGER_TYPE || code2 == BITINT_TYPE))
{
if (!null_pointer_constant_p (orig_op2))
- pedwarn (colon_loc, 0,
+ pedwarn (colon_loc, OPT_Wint_conversion,
"pointer/integer type mismatch in conditional expression");
else
{
&& (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
{
if (!null_pointer_constant_p (orig_op1))
- pedwarn (colon_loc, 0,
+ pedwarn (colon_loc, OPT_Wint_conversion,
"pointer/integer type mismatch in conditional expression");
else
{
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+const char *
+f1 (int flag)
+{
+ return flag ? "" : 1; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */
+}
+
+const char *
+f2 (int flag)
+{
+ return flag ? 1 : ""; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */
+}