[clang] cff99b7 - Add a flag to disable "duplicate definition of category" warnings

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 3 16:27:07 PDT 2023


Author: Akira Hatanaka
Date: 2023-07-03T16:25:22-07:00
New Revision: cff99b76ac4f502ceba897a62db658667f1237f3

URL: https://github.com/llvm/llvm-project/commit/cff99b76ac4f502ceba897a62db658667f1237f3
DIFF: https://github.com/llvm/llvm-project/commit/cff99b76ac4f502ceba897a62db658667f1237f3.diff

LOG: Add a flag to disable "duplicate definition of category" warnings

Differential Revision: https://reviews.llvm.org/D154251

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticCommonKinds.td
    clang/test/Misc/warning-flags.c
    clang/test/SemaObjC/check-dup-objc-decls-1.m

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 3ccdaada1ee270..ee994e765e09a9 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -305,7 +305,8 @@ def warn_slh_does_not_support_asm_goto : Warning<
 
 // Sema && Serialization
 def warn_dup_category_def : Warning<
-  "duplicate definition of category %1 on interface %0">;
+  "duplicate definition of category %1 on interface %0">,
+  InGroup<DiagGroup<"objc-duplicate-category-definition">>;
 
 // Targets
 

diff  --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index ac9a1f9f010c2e..c587337da5933a 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/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 (66):
+CHECK: Warnings without flags (65):
 
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
@@ -46,7 +46,6 @@ CHECK-NEXT:   warn_double_const_requires_fp64
 CHECK-NEXT:   warn_drv_assuming_mfloat_abi_is
 CHECK-NEXT:   warn_drv_clang_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
-CHECK-NEXT:   warn_dup_category_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_fe_backend_unsupported

diff  --git a/clang/test/SemaObjC/check-dup-objc-decls-1.m b/clang/test/SemaObjC/check-dup-objc-decls-1.m
index 8867afef7159a9..94b33d5cfe801c 100644
--- a/clang/test/SemaObjC/check-dup-objc-decls-1.m
+++ b/clang/test/SemaObjC/check-dup-objc-decls-1.m
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -Wno-objc-duplicate-category-definition -DIGNORE_DUP_CAT %s
 
 @interface Foo // expected-note {{previous definition is here}}
 @end
@@ -41,8 +42,13 @@ @protocol DP<P> @end
 @protocol DP<Q> @end
 #pragma clang diagnostic pop
 
- at interface A(Cat)<P> @end // expected-note {{previous definition is here}}
- at interface A(Cat)<Q> @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}}
+ at interface A(Cat)<P> @end
+ at interface A(Cat)<Q> @end
+
+#ifndef IGNORE_DUP_CAT
+// expected-note at -4 {{previous definition is here}}
+// expected-warning at -4 {{duplicate definition of category 'Cat' on interface 'A'}}
+#endif
 
 // rdar 7626768
 @class NSString;


        


More information about the cfe-commits mailing list