From: Eli Friedman Date: Sat, 5 May 2018 00:09:51 +0000 (+0000) Subject: Add warning flag -Wordered-compare-function-pointers. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b579d894c6a3efa21d358a067b01af4c62dc78b;p=clang Add warning flag -Wordered-compare-function-pointers. The C standard doesn't allow comparisons like "f1 < f2" (where f1 and f2 are function pointers), but we allow them as an extension. Add a warning flag to control this warning. Differential Revision: https://reviews.llvm.org/D46155 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331570 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index f0a325c46f..053f2fc85d 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -5932,7 +5932,8 @@ def ext_typecheck_ordered_comparison_of_pointer_and_zero : Extension< def err_typecheck_ordered_comparison_of_pointer_and_zero : Error< "ordered comparison between pointer and zero (%0 and %1)">; def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn< - "ordered comparison of function pointers (%0 and %1)">; + "ordered comparison of function pointers (%0 and %1)">, + InGroup>; def ext_typecheck_comparison_of_fptr_to_void : Extension< "equality comparison between function pointer and void pointer (%0 and %1)">; def err_typecheck_comparison_of_fptr_to_void : Error< diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index c8ee9bcfda..4f9469f8e5 100644 --- a/test/Misc/warning-flags.c +++ b/test/Misc/warning-flags.c @@ -18,7 +18,7 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (77): +CHECK: Warnings without flags (76): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -31,7 +31,6 @@ CHECK-NEXT: ext_plain_complex CHECK-NEXT: ext_template_arg_extra_parens CHECK-NEXT: ext_typecheck_comparison_of_pointer_integer CHECK-NEXT: ext_typecheck_cond_incompatible_operands -CHECK-NEXT: ext_typecheck_ordered_comparison_of_function_pointers CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_integer CHECK-NEXT: ext_using_undefined_std CHECK-NEXT: pp_invalid_string_literal