On Thu, 18 Aug 2022, Jose E. Marchesi via Gcc-patches wrote: > diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc > index de8780a1502..04af02add37 100644 > --- a/gcc/c/c-typeck.cc > +++ b/gcc/c/c-typeck.cc > @@ -12397,7 +12397,8 @@ build_binary_op (location_t location, enum tree_code > code, > } > else > /* Avoid warning about the volatile ObjC EH puts on decls. */ > - if (!objc_ok) > + if (!objc_ok > + && warn_compare_distinct_pointer_types) > pedwarn (location, 0, > "comparison of distinct pointer types lacks a cast"); > > @@ -12517,8 +12518,9 @@ build_binary_op (location_t location, enum tree_code > code, > int qual = ENCODE_QUAL_ADDR_SPACE (as_common); > result_type = build_pointer_type > (build_qualified_type (void_type_node, qual)); > - pedwarn (location, 0, > - "comparison of distinct pointer types lacks a cast"); > + if (warn_compare_distinct_pointer_types) > + pedwarn (location, 0, > + "comparison of distinct pointer types lacks a > cast");
I think this should use OPT_Wcompare_distinct_pointer_types in place of 0, and then you shouldn't need to check warn_compare_distinct_pointer_types (as well as the diagnostic then automatically telling the user what option controls it). -- Joseph S. Myers jos...@codesourcery.com