diff options
author | Florian Weimer <fweimer@redhat.com> | 2023-10-20 21:27:52 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2023-10-20 22:15:50 +0200 |
commit | 857a6ee25ff5cbb97715de4dd97e1641285c6085 (patch) | |
tree | efa2bb606e67591bac8c90f501535212810e4c72 /gcc/c/c-typeck.cc | |
parent | 8f75e6cf583cf8db16334c0ba323801cbc9f4e7f (diff) | |
download | gcc-857a6ee25ff5cbb97715de4dd97e1641285c6085.zip gcc-857a6ee25ff5cbb97715de4dd97e1641285c6085.tar.gz gcc-857a6ee25ff5cbb97715de4dd97e1641285c6085.tar.bz2 |
c: -Wincompatible-pointer-types should cover mismatches in ?:
gcc/c/
PR c/109826
PR other/44209
* c-typeck.cc (build_conditional_expr): Use
OPT_Wincompatible_pointer_types for pointer mismatches.
Emit location information for the operand.
gcc/testsuite/
* gcc.dg/Wincompatible-pointer-types-2.c: New.
* gcc.dg/Wincompatible-pointer-types-3.c: New.
* gcc.dg/Wincompatible-pointer-types-4.c: New.
Diffstat (limited to 'gcc/c/c-typeck.cc')
-rw-r--r-- | gcc/c/c-typeck.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index f7ce13a..c73153c 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -5564,14 +5564,14 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, else { int qual = ENCODE_QUAL_ADDR_SPACE (as_common); - if (bltin1 && bltin2) - warning_at (colon_loc, OPT_Wincompatible_pointer_types, - "pointer type mismatch between %qT and %qT " - "of %qD and %qD in conditional expression", - type1, type2, bltin1, bltin2); - else - pedwarn (colon_loc, 0, - "pointer type mismatch in conditional expression"); + if (emit_diagnostic (bltin1 && bltin2 ? DK_WARNING : DK_PEDWARN, + colon_loc, OPT_Wincompatible_pointer_types, + "pointer type mismatch " + "in conditional expression")) + { + inform (op1_loc, "first expression has type %qT", type1); + inform (op2_loc, "second expression has type %qT", type2); + } result_type = build_pointer_type (build_qualified_type (void_type_node, qual)); } |