summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-23 22:38:38 +0000
committerChris Lattner <sabre@nondot.org>2008-11-23 22:38:38 +0000
commit88dcd2a1ab2f4cc87c7d4192f21c9323f5b3960c (patch)
tree96392d0a8df8f7ca5edb12ab416a918d35d5d22b /clang
parente3d20d954503fef1256b50977f7e2c9507452c1e (diff)
downloadbcm5719-llvm-88dcd2a1ab2f4cc87c7d4192f21c9323f5b3960c.tar.gz
bcm5719-llvm-88dcd2a1ab2f4cc87c7d4192f21c9323f5b3960c.zip
Tweak duplicate category diagnostic to work like the duplicate protocol diagnostic.
Also, point out where the previous decl was. This unxfails two tests. llvm-svn: 59918
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/DiagnosticKinds.def12
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp1
-rw-r--r--clang/test/SemaObjC/category-1.m21
-rw-r--r--clang/test/SemaObjC/check-dup-objc-decls-1.m5
4 files changed, 22 insertions, 17 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def
index c08d55344f7..860888f026d 100644
--- a/clang/include/clang/Basic/DiagnosticKinds.def
+++ b/clang/include/clang/Basic/DiagnosticKinds.def
@@ -23,6 +23,14 @@
// ERROR - Error, compilation will stop after parsing completes.
//===----------------------------------------------------------------------===//
+// Common Helpers
+//===----------------------------------------------------------------------===//
+
+DIAG(note_previous_definition, NOTE,
+ "previous definition is here")
+
+
+//===----------------------------------------------------------------------===//
// Lexer Diagnostics
//===----------------------------------------------------------------------===//
@@ -126,8 +134,6 @@ DIAG(ext_pp_bad_vaargs_use, EXTENSION,
"__VA_ARGS__ can only appear in the expansion of a C99 variadic macro")
DIAG(ext_pp_macro_redef, EXTENSION,
"%0 macro redefined")
-DIAG(note_previous_definition, NOTE,
- "previous definition is here")
DIAG(ext_variadic_macro, EXTENSION,
"variadic macros were introduced in C99")
DIAG(ext_named_variadic_macro, EXTENSION,
@@ -455,7 +461,7 @@ DIAG(err_duplicate_protocol_def, ERROR,
DIAG(err_undef_interface, ERROR,
"cannot find interface declaration for %0")
DIAG(warn_dup_category_def, WARNING,
- "duplicate interface declaration for category %0 (%1)")
+ "duplicate definition of category %1 on interface %0")
DIAG(warn_undef_interface, WARNING,
"cannot find interface declaration for %0")
DIAG(err_dup_implementation_class, ERROR,
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 49bfad7634e..7ffae4725c8 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -406,6 +406,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
if (CategoryName && CDeclChain->getIdentifier() == CategoryName) {
Diag(CategoryLoc, diag::warn_dup_category_def)
<< ClassName << CategoryName;
+ Diag(CDeclChain->getLocation(), diag::note_previous_definition);
break;
}
}
diff --git a/clang/test/SemaObjC/category-1.m b/clang/test/SemaObjC/category-1.m
index 8ba15d39732..84f4c1953e5 100644
--- a/clang/test/SemaObjC/category-1.m
+++ b/clang/test/SemaObjC/category-1.m
@@ -1,29 +1,28 @@
// RUN: clang -fsyntax-only -verify %s
-// XFAIL
@interface MyClass1 @end
@protocol p1,p2,p3;
-@interface MyClass1 (Category1) <p1> // expected-warning {{cannot find protocol definition for 'p1'}}
+@interface MyClass1 (Category1) <p1> // expected-warning {{cannot find protocol definition for 'p1'}} expected-note {{previous definition is here}}
@end
-@interface MyClass1 (Category1) // expected-warning {{duplicate interface declaration for category 'MyClass1(Category1)'}}
+@interface MyClass1 (Category1) // expected-warning {{duplicate definition of category 'Category1' on interface 'MyClass1'}}
@end
@interface MyClass1 (Category3)
@end
-@interface MyClass1 (Category4) @end
+@interface MyClass1 (Category4) @end // expected-note {{previous definition is here}}
@interface MyClass1 (Category5) @end
@interface MyClass1 (Category6) @end
-@interface MyClass1 (Category7) @end
-@interface MyClass1 (Category8) @end
+@interface MyClass1 (Category7) @end // expected-note {{previous definition is here}}
+@interface MyClass1 (Category8) @end // expected-note {{previous definition is here}}
-@interface MyClass1 (Category4) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category4)'}}
-@interface MyClass1 (Category7) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category7)'}}
-@interface MyClass1 (Category8) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category8)'}}
+@interface MyClass1 (Category4) @end // expected-warning {{duplicate definition of category 'Category4' on interface 'MyClass1'}}
+@interface MyClass1 (Category7) @end // expected-warning {{duplicate definition of category 'Category7' on interface 'MyClass1'}}
+@interface MyClass1 (Category8) @end // expected-warning {{duplicate definition of category 'Category8' on interface 'MyClass1'}}
@protocol p3 @end
@@ -45,10 +44,10 @@
@interface XCRemoteComputerManager()
@end
-@interface XCRemoteComputerManager(x)
+@interface XCRemoteComputerManager(x) // expected-note {{previous definition is here}}
@end
-@interface XCRemoteComputerManager(x) // expected-warning {{duplicate interface declaration for category 'XCRemoteComputerManager(x)'}}
+@interface XCRemoteComputerManager(x) // expected-warning {{duplicate definition of category 'x' on interface 'XCRemoteComputerManager'}}
@end
@implementation XCRemoteComputerManager
diff --git a/clang/test/SemaObjC/check-dup-objc-decls-1.m b/clang/test/SemaObjC/check-dup-objc-decls-1.m
index 5f55cfdb271..a634d0e6da4 100644
--- a/clang/test/SemaObjC/check-dup-objc-decls-1.m
+++ b/clang/test/SemaObjC/check-dup-objc-decls-1.m
@@ -1,5 +1,4 @@
// RUN: clang -fsyntax-only -verify %s
-// XFAIL
@interface Foo // expected-error {{previous definition is here}}
@end
@@ -36,5 +35,5 @@ void Gorf() // expected-error {{redefinition of 'Gorf' as different kind of symb
@protocol PP<P> @end
@protocol PP<Q> @end // expected-error {{duplicate protocol declaration of 'PP'}}
-@interface A(Cat)<P> @end
-@interface A(Cat)<Q> @end // expected-warning {{duplicate interface declaration for category 'A(Cat)'}}
+@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'}}
OpenPOWER on IntegriCloud