From: Chris Lattner Date: Sun, 23 Nov 2008 22:46:27 +0000 (+0000) Subject: make some objc redefinition warnings more consistent: call definitions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8b96aff63e24ff1509f112de871f697aaea55f9;p=clang make some objc redefinition warnings more consistent: call definitions "definitions", not declarations. Point out the location of the original definition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59919 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def index 860888f026..cbf7590058 100644 --- a/include/clang/Basic/DiagnosticKinds.def +++ b/include/clang/Basic/DiagnosticKinds.def @@ -453,11 +453,11 @@ DIAG(err_objc_concat_string, ERROR, DIAG(err_undef_superclass, ERROR, "cannot find interface declaration for %0, superclass of %1") DIAG(err_duplicate_class_def, ERROR, - "duplicate interface declaration for class '%0'") + "duplicate interface definition for class '%0'") DIAG(warn_undef_protocolref, WARNING, "cannot find protocol definition for %0") DIAG(err_duplicate_protocol_def, ERROR, - "duplicate protocol declaration of %0") + "duplicate protocol definition of %0") DIAG(err_undef_interface, ERROR, "cannot find interface declaration for %0") DIAG(warn_dup_category_def, WARNING, diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 7ffae4725c..c030a370e4 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -76,6 +76,8 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, // Class already seen. Is it a forward declaration? if (!IDecl->isForwardDecl()) { Diag(AtInterfaceLoc, diag::err_duplicate_class_def) << IDecl->getName(); + Diag(IDecl->getLocation(), diag::note_previous_definition); + // Return the previous class interface. // FIXME: don't leak the objects passed in! return IDecl; @@ -188,6 +190,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, // Protocol already seen. Better be a forward protocol declaration if (!PDecl->isForwardDecl()) { Diag(ProtocolLoc, diag::err_duplicate_protocol_def) << ProtocolName; + Diag(PDecl->getLocation(), diag::note_previous_definition); // Just return the protocol we already had. // FIXME: don't leak the objects passed in! return PDecl; diff --git a/test/SemaObjC/alias-test-2.m b/test/SemaObjC/alias-test-2.m index 5f3bfcbba7..bdaeefe5a3 100644 --- a/test/SemaObjC/alias-test-2.m +++ b/test/SemaObjC/alias-test-2.m @@ -3,13 +3,13 @@ // Note: GCC doesn't produce any of the following errors. @interface Super @end // expected-error {{previous definition is here}} -@interface MyWpModule @end +@interface MyWpModule @end // expected-note {{previous definition is here}} @compatibility_alias MyAlias MyWpModule; @compatibility_alias AliasForSuper Super; -@interface MyAlias : AliasForSuper // expected-error {{duplicate interface declaration for class 'MyWpModule'}} +@interface MyAlias : AliasForSuper // expected-error {{duplicate interface definition for class 'MyWpModule'}} @end @implementation MyAlias : AliasForSuper // expected-error {{conflicting super class name 'Super'}} diff --git a/test/SemaObjC/check-dup-objc-decls-1.m b/test/SemaObjC/check-dup-objc-decls-1.m index a634d0e6da..28c6068afd 100644 --- a/test/SemaObjC/check-dup-objc-decls-1.m +++ b/test/SemaObjC/check-dup-objc-decls-1.m @@ -29,11 +29,11 @@ void Gorf() // expected-error {{redefinition of 'Gorf' as different kind of symb @protocol P -im1; @end @protocol Q -im2; @end -@interface A

@end -@interface A @end // expected-error {{duplicate interface declaration for class 'A'}} +@interface A

@end // expected-note {{previous definition is here}} +@interface A @end // expected-error {{duplicate interface definition for class 'A'}} -@protocol PP

@end -@protocol PP @end // expected-error {{duplicate protocol declaration of 'PP'}} +@protocol PP

@end // expected-note {{previous definition is here}} +@protocol PP @end // expected-error {{duplicate protocol definition of 'PP'}} @interface A(Cat)

@end // expected-note {{previous definition is here}} @interface A(Cat) @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}} diff --git a/test/SemaObjC/class-def-test-1.m b/test/SemaObjC/class-def-test-1.m index 3dc687b99a..cf0ef53cae 100644 --- a/test/SemaObjC/class-def-test-1.m +++ b/test/SemaObjC/class-def-test-1.m @@ -10,9 +10,9 @@ typedef int INTF; // expected-error {{previous definition is here}} @interface OBJECT @end // expected-error {{previous definition is here}} -@interface INTF1 : OBJECT @end +@interface INTF1 : OBJECT @end // expected-note {{previous definition is here}} -@interface INTF1 : OBJECT @end // expected-error {{duplicate interface declaration for class 'INTF1'}} +@interface INTF1 : OBJECT @end // expected-error {{duplicate interface definition for class 'INTF1'}} typedef int OBJECT; // expected-error {{previous definition is here}} \ expected-error {{redefinition of 'OBJECT' as different kind of symbol}} diff --git a/test/SemaObjC/forward-class-1.m b/test/SemaObjC/forward-class-1.m index 2b9369ba5f..5eb36e704a 100644 --- a/test/SemaObjC/forward-class-1.m +++ b/test/SemaObjC/forward-class-1.m @@ -14,11 +14,11 @@ @interface INTF1 : FOO @end -@interface INTF2 : INTF1 +@interface INTF2 : INTF1 // expected-note {{previous definition is here}} @end @class INTF1, INTF2; -@interface INTF2 : INTF1 // expected-error {{duplicate interface declaration for class 'INTF2'}} +@interface INTF2 : INTF1 // expected-error {{duplicate interface definition for class 'INTF2'}} @end diff --git a/test/SemaObjC/protocol-test-2.m b/test/SemaObjC/protocol-test-2.m index 1a7fc9ce3c..e5fff2da63 100644 --- a/test/SemaObjC/protocol-test-2.m +++ b/test/SemaObjC/protocol-test-2.m @@ -15,10 +15,10 @@ @protocol p1 @end -@protocol PROTO +@protocol PROTO // expected-note {{previous definition is here}} @end -@protocol PROTO // expected-error {{duplicate protocol declaration of 'PROTO'}} +@protocol PROTO // expected-error {{duplicate protocol definition of 'PROTO'}} @end @protocol PROTO3 diff --git a/test/SemaObjC/undef-superclass-1.m b/test/SemaObjC/undef-superclass-1.m index 7e12463654..ba233f8c4e 100644 --- a/test/SemaObjC/undef-superclass-1.m +++ b/test/SemaObjC/undef-superclass-1.m @@ -7,7 +7,7 @@ @interface SUPER @end -@interface INTF1 : SUPER +@interface INTF1 : SUPER // expected-note {{previous definition is here}} @end @interface INTF2 : INTF1 @@ -16,7 +16,7 @@ @interface INTF3 : Y // expected-error {{cannot find interface declaration for 'Y', superclass of 'INTF3'}} @end -@interface INTF1 // expected-error {{duplicate interface declaration for class 'INTF1'}} +@interface INTF1 // expected-error {{duplicate interface definition for class 'INTF1'}} @end @implementation SUPER