[cfe-commits] [Patch] Fix for PR2709
Douglas Gregor
dgregor at apple.com
Tue Nov 15 09:46:34 PST 2011
On Nov 15, 2011, at 8:45 AM, Erik Verbruggen wrote:
> Hi all,
>
> Attached is a patch for PR2709. It is against trunk rev #144646. Two questions:
> - are there more cases to cover than the one in the PR
There are @protocols and @implementations to consider.
> - should I add the warning to the Misc/warning-flags.c test, or should I add it to a group (and if so, which one, because there are more warnings of the same kind which are not in a group)...?
We're moving toward having all warnings in groups. Please put the warning in a group.
@@ -145,7 +145,11 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation atLoc,
ParsedAttributes &attrs) {
assert(Tok.isObjCAtKeyword(tok::objc_interface) &&
"ParseObjCAtInterfaceDeclaration(): Expected @interface");
- ConsumeToken(); // the "interface" identifier
+ const IdentifierInfo *IFaceII = Tok.getIdentifierInfo();
+ const SourceLocation IFaceTok = ConsumeToken(); // the "interface" identifier
+ if (Actions.CurContext->isObjCContainer())
+ Diag(IFaceTok, diag::warn_objc_nested_container_decl)
+ << IFaceII->getName();
Two comments: (1) the parser shouldn't be poking at Actions.CurContext. Most likely, this check should move into Sema. (2) it seems like the most common case of having an @interface/@implementation/@protocol nested inside another one is actually a missing @end; it's probably best to provide that as a Fix-It and pretend as if the @end were there.
- Doug
More information about the cfe-commits
mailing list