[cfe-commits] r110417 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaObjCXX/objc-decls-inside-namespace.mm
John McCall
rjmccall at apple.com
Thu Aug 5 17:46:05 PDT 2010
Author: rjmccall
Date: Thu Aug 5 19:46:05 2010
New Revision: 110417
URL: http://llvm.org/viewvc/llvm-project?rev=110417&view=rev
Log:
Properly pop out of Objective-C method declarations when they are (ill-formedly)
found within contexts other than the translation unit.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjCXX/objc-decls-inside-namespace.mm
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=110417&r1=110416&r2=110417&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug 5 19:46:05 2010
@@ -343,8 +343,10 @@
return DC;
}
+ // ObjCMethodDecls are parsed (for some reason) outside the context
+ // of the class.
if (isa<ObjCMethodDecl>(DC))
- return Context.getTranslationUnitDecl();
+ return DC->getLexicalParent()->getLexicalParent();
return DC->getLexicalParent();
}
Modified: cfe/trunk/test/SemaObjCXX/objc-decls-inside-namespace.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objc-decls-inside-namespace.mm?rev=110417&r1=110416&r2=110417&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/objc-decls-inside-namespace.mm (original)
+++ cfe/trunk/test/SemaObjCXX/objc-decls-inside-namespace.mm Thu Aug 5 19:46:05 2010
@@ -23,5 +23,10 @@
@implementation A(C) //expected-error{{Objective-C declarations may only appear in global scope}}
@end
+ at interface B @end //expected-error{{Objective-C declarations may only appear in global scope}}
+ at implementation B //expected-error{{Objective-C declarations may only appear in global scope}}
++ (void) foo {}
+ at end
+
}
More information about the cfe-commits
mailing list