[cfe-commits] r68474 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclObjC.cpp test/SemaObjC/check-dup-objc-decls-1.m test/SemaObjC/protocol-test-2.m

Fariborz Jahanian fjahanian at apple.com
Mon Apr 6 16:43:33 PDT 2009


Author: fjahanian
Date: Mon Apr  6 18:43:32 2009
New Revision: 68474

URL: http://llvm.org/viewvc/llvm-project?rev=68474&view=rev
Log:
Warn instead of error on duplicate protocol definitions.
Be kind to so many projects which are doing this (and be
like gcc).

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
    cfe/trunk/test/SemaObjC/protocol-test-2.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=68474&r1=68473&r2=68474&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr  6 18:43:32 2009
@@ -128,7 +128,7 @@
 def warn_previous_alias_decl : Warning<"previously declared alias is ignored">;
 def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">;
 def warn_undef_interface : Warning<"cannot find interface declaration for %0">;
-def err_duplicate_protocol_def : Error<"duplicate protocol definition of %0">;
+def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">;
 def err_protocol_has_circular_dependency : Error<
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">;

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=68474&r1=68473&r2=68474&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Apr  6 18:43:32 2009
@@ -246,8 +246,7 @@
   if (PDecl) {
     // Protocol already seen. Better be a forward protocol declaration
     if (!PDecl->isForwardDecl()) {
-      PDecl->setInvalidDecl();
-      Diag(ProtocolLoc, diag::err_duplicate_protocol_def) << ProtocolName;
+      Diag(ProtocolLoc, diag::warn_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!

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=68474&r1=68473&r2=68474&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m (original)
+++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Mon Apr  6 18:43:32 2009
@@ -33,7 +33,7 @@
 @interface A<Q> @end  // expected-error {{duplicate interface definition for class 'A'}}
 
 @protocol PP<P> @end  // expected-note {{previous definition is here}}
- at protocol PP<Q> @end  // expected-error {{duplicate protocol definition of 'PP'}}
+ at protocol PP<Q> @end  // expected-warning {{duplicate protocol definition of 'PP'}}
 
 @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'}}

Modified: cfe/trunk/test/SemaObjC/protocol-test-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocol-test-2.m?rev=68474&r1=68473&r2=68474&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/protocol-test-2.m (original)
+++ cfe/trunk/test/SemaObjC/protocol-test-2.m Mon Apr  6 18:43:32 2009
@@ -18,7 +18,7 @@
 @protocol PROTO<p1>     // expected-note {{previous definition is here}}
 @end
 
- at protocol PROTO<p1>	// expected-error {{duplicate protocol definition of 'PROTO'}}
+ at protocol PROTO<p1>	// expected-warning {{duplicate protocol definition of 'PROTO'}}
 @end
 
 @protocol PROTO3<p1, p1>





More information about the cfe-commits mailing list