Author: lattner Date: Sun Nov 23 16:38:38 2008 New Revision: 59918 URL: http://llvm.org/viewvc/llvm-project?rev=59918&view=rev Log: Tweak duplicate category diagnostic to work like the duplicate protocol diagnostic. Also, point out where the previous decl was. This unxfails two tests.
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/test/SemaObjC/category-1.m cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=59918&r1=59917&r2=59918&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original) +++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Sun Nov 23 16:38:38 2008 @@ -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 @@ "__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_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, Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=59918&r1=59917&r2=59918&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Nov 23 16:38:38 2008 @@ -406,6 +406,7 @@ if (CategoryName && CDeclChain->getIdentifier() == CategoryName) { Diag(CategoryLoc, diag::warn_dup_category_def) << ClassName << CategoryName; + Diag(CDeclChain->getLocation(), diag::note_previous_definition); break; } } Modified: cfe/trunk/test/SemaObjC/category-1.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/category-1.m?rev=59918&r1=59917&r2=59918&view=diff ============================================================================== --- cfe/trunk/test/SemaObjC/category-1.m (original) +++ cfe/trunk/test/SemaObjC/category-1.m Sun Nov 23 16:38:38 2008 @@ -1,29 +1,28 @@ // RUN: clang -fsyntax-only -verify %s -// XFAIL @interface MyClass1 @end @protocol p1,p2,p3; [EMAIL PROTECTED] MyClass1 (Category1) <p1> // expected-warning {{cannot find protocol definition for 'p1'}} [EMAIL PROTECTED] MyClass1 (Category1) <p1> // expected-warning {{cannot find protocol definition for 'p1'}} expected-note {{previous definition is here}} @end [EMAIL PROTECTED] MyClass1 (Category1) // expected-warning {{duplicate interface declaration for category 'MyClass1(Category1)'}} [EMAIL PROTECTED] MyClass1 (Category1) // expected-warning {{duplicate definition of category 'Category1' on interface 'MyClass1'}} @end @interface MyClass1 (Category3) @end [EMAIL PROTECTED] MyClass1 (Category4) @end [EMAIL PROTECTED] MyClass1 (Category4) @end // expected-note {{previous definition is here}} @interface MyClass1 (Category5) @end @interface MyClass1 (Category6) @end [EMAIL PROTECTED] MyClass1 (Category7) @end [EMAIL PROTECTED] MyClass1 (Category8) @end [EMAIL PROTECTED] MyClass1 (Category7) @end // expected-note {{previous definition is here}} [EMAIL PROTECTED] MyClass1 (Category8) @end // expected-note {{previous definition is here}} [EMAIL PROTECTED] MyClass1 (Category4) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category4)'}} [EMAIL PROTECTED] MyClass1 (Category7) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category7)'}} [EMAIL PROTECTED] MyClass1 (Category8) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category8)'}} [EMAIL PROTECTED] MyClass1 (Category4) @end // expected-warning {{duplicate definition of category 'Category4' on interface 'MyClass1'}} [EMAIL PROTECTED] MyClass1 (Category7) @end // expected-warning {{duplicate definition of category 'Category7' on interface 'MyClass1'}} [EMAIL PROTECTED] MyClass1 (Category8) @end // expected-warning {{duplicate definition of category 'Category8' on interface 'MyClass1'}} @protocol p3 @end @@ -45,10 +44,10 @@ @interface XCRemoteComputerManager() @end [EMAIL PROTECTED] XCRemoteComputerManager(x) [EMAIL PROTECTED] XCRemoteComputerManager(x) // expected-note {{previous definition is here}} @end [EMAIL PROTECTED] XCRemoteComputerManager(x) // expected-warning {{duplicate interface declaration for category 'XCRemoteComputerManager(x)'}} [EMAIL PROTECTED] XCRemoteComputerManager(x) // expected-warning {{duplicate definition of category 'x' on interface 'XCRemoteComputerManager'}} @end @implementation XCRemoteComputerManager Modified: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m?rev=59918&r1=59917&r2=59918&view=diff ============================================================================== --- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m (original) +++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Sun Nov 23 16:38:38 2008 @@ -1,5 +1,4 @@ // RUN: clang -fsyntax-only -verify %s -// XFAIL @interface Foo // expected-error {{previous definition is here}} @end @@ -36,5 +35,5 @@ @protocol PP<P> @end @protocol PP<Q> @end // expected-error {{duplicate protocol declaration of 'PP'}} [EMAIL PROTECTED] A(Cat)<P> @end [EMAIL PROTECTED] A(Cat)<Q> @end // expected-warning {{duplicate interface declaration for category 'A(Cat)'}} [EMAIL PROTECTED] A(Cat)<P> @end // expected-note {{previous definition is here}} [EMAIL PROTECTED] A(Cat)<Q> @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}} _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits