Warn instead of error on duplicate protocol definitions.

Be kind to so many projects which are doing this (and be
like gcc).

llvm-svn: 68474
This commit is contained in:
Fariborz Jahanian 2009-04-06 23:43:32 +00:00
parent c4c9ed0f9b
commit 54d569c51d
4 changed files with 4 additions and 5 deletions

View File

@ -128,7 +128,7 @@ def err_undef_superclass : Error<
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">;

View File

@ -246,8 +246,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
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!

View File

@ -33,7 +33,7 @@ void Gorf() // expected-error {{redefinition of 'Gorf' as different kind of symb
@interface A<Q> @end // expected-error {{duplicate interface definition for class 'A'}}
@protocol PP<P> @end // expected-note {{previous definition is here}}
@protocol PP<Q> @end // expected-error {{duplicate protocol definition of 'PP'}}
@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'}}

View File

@ -18,7 +18,7 @@
@protocol PROTO<p1> // expected-note {{previous definition is here}}
@end
@protocol PROTO<p1> // expected-error {{duplicate protocol definition of 'PROTO'}}
@protocol PROTO<p1> // expected-warning {{duplicate protocol definition of 'PROTO'}}
@end
@protocol PROTO3<p1, p1>