[PATCH] D49462: [ObjC] Error out when using forward-declared protocol in a @protocol expression
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 17 18:58:25 PDT 2018
rjmccall added a comment.
Hmm. I think this is a reasonable change to make to the language. Have you investigated to see if this causes source-compatibility problems?
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:849
+def err_atprotocol_protocol : Error<
+ "@protocol is using a forward protocol declaration of %0">;
def warn_readonly_property : Warning<
----------------
I think that's the only warning in `-Wat-protocol`; we can at least anonymize it and leave a comment saying it's now empty.
================
Comment at: lib/Sema/SemaExprObjC.cpp:1235
+ } else
PDecl = PDecl->getDefinition();
----------------
Please brace the second clause here. I think even the people who don't generally use braces still advise being consistent within a single if-else chain.
================
Comment at: test/CodeGenObjC/forward-declare-protocol-gnu.m:6
-Protocol *getProtocol(void)
-{
- return @protocol(P);
-}
+ at interface I <P>
+ at end
----------------
Does this really not require a definition of `P`? Ugh. I wonder if that's reasonable to fix, too.
================
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
----------------
Why did this test need to change?
Repository:
rC Clang
https://reviews.llvm.org/D49462
More information about the cfe-commits
mailing list