[PATCH] D49462: [ObjC] Error out when using forward-declared protocol in a @protocol expression

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 16 16:30:38 PDT 2018


arphaman added a comment.

Sorry for the delay.

In https://reviews.llvm.org/D49462#1166032, @rjmccall wrote:

> Hmm.  I think this is a reasonable change to make to the language.  Have you investigated to see if this causes source-compatibility problems?


Yes, I tested this change on internal code base. There's an impact, but the impact is fairly minimal. The biggest issue is actually in some Swift overlay: https://github.com/apple/swift/blob/c275826a41aca8268719061636efc12717b8dae1/stdlib/public/SDK/Dispatch/Dispatch.mm#L36



================
Comment at: test/CodeGenObjC/forward-declare-protocol-gnu.m:6
 
-Protocol *getProtocol(void)
-{
-	        return @protocol(P);
-}
+ at interface I <P>
+ at end
----------------
rjmccall wrote:
> Does this really not require a definition of `P`?  Ugh.  I wonder if that's reasonable to fix, too.
Nope, we don't emit the protocol metadata for it. It might make sense to require the definition with the implementation?


================
Comment at: test/Parser/objc-cxx-keyword-identifiers.mm:22
+ at protocol P2;
+ at protocol delete // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}}
+ at end
----------------
rjmccall wrote:
> Why did this test need to change?
We need to declare `delete` because it's used in a `@protocol` expression on line 63.


Repository:
  rC Clang

https://reviews.llvm.org/D49462





More information about the cfe-commits mailing list