Skip to content

Commit

Permalink
Add a flag to disable "duplicate definition of category" warnings
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D154251
  • Loading branch information
ahatanaka committed Jul 3, 2023
1 parent 369930b commit cff99b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/DiagnosticCommonKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions clang/test/Misc/warning-flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions clang/test/SemaObjC/check-dup-objc-decls-1.m
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -41,8 +42,13 @@ @protocol DP<P> @end
@protocol DP<Q> @end
#pragma clang diagnostic pop

@interface A(Cat)<P> @end // expected-note {{previous definition is here}}
@interface A(Cat)<Q> @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}}
@interface A(Cat)<P> @end
@interface A(Cat)<Q> @end

#ifndef IGNORE_DUP_CAT
// expected-note@-4 {{previous definition is here}}
// expected-warning@-4 {{duplicate definition of category 'Cat' on interface 'A'}}
#endif

// rdar 7626768
@class NSString;
Expand Down

0 comments on commit cff99b7

Please sign in to comment.