PI.IdentLoc = SourceLocation(); // synthesized vars have a null location.
PI.InvalidType = false;
if (MDecl->isInstance()) {
- QualType selfTy = Context.getObjCInterfaceType(MDecl->getClassInterface());
- selfTy = Context.getPointerType(selfTy);
- PI.TypeInfo = selfTy.getAsOpaquePtr();
+ ObjCInterfaceDecl *OID = MDecl->getClassInterface();
+ // There may be no interface context due to error in declaration of the
+ // interface (which has been reported). Recover gracefully
+ if (OID) {
+ QualType selfTy = Context.getObjCInterfaceType(OID);
+ selfTy = Context.getPointerType(selfTy);
+ PI.TypeInfo = selfTy.getAsOpaquePtr();
+ }
} else
PI.TypeInfo = Context.getObjCIdType().getAsOpaquePtr();
CurMethodDecl->setSelfDecl(ActOnParamDeclarator(PI, FnBodyScope));
Stmt *First = static_cast<Stmt*>(first);
Expr *Second = static_cast<Expr*>(second);
Stmt *Body = static_cast<Stmt*>(body);
- QualType FirstType;
- if (DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
- FirstType = cast<ValueDecl>(DS->getDecl())->getType();
- // C99 6.8.5p3: The declaration part of a 'for' statement shall only declare
- // identifiers for objects having storage class 'auto' or 'register'.
- ScopedDecl *D = DS->getDecl();
- BlockVarDecl *BVD = cast<BlockVarDecl>(D);
- if (!BVD->hasLocalStorage())
- return Diag(BVD->getLocation(), diag::err_non_variable_decl_in_for);
- if (D->getNextDeclarator())
- return Diag(D->getLocation(), diag::err_toomany_element_decls);
+ if (First) {
+ QualType FirstType;
+ if (DeclStmt *DS = dyn_cast<DeclStmt>(First)) {
+ FirstType = cast<ValueDecl>(DS->getDecl())->getType();
+ // C99 6.8.5p3: The declaration part of a 'for' statement shall only declare
+ // identifiers for objects having storage class 'auto' or 'register'.
+ ScopedDecl *D = DS->getDecl();
+ BlockVarDecl *BVD = cast<BlockVarDecl>(D);
+ if (!BVD->hasLocalStorage())
+ return Diag(BVD->getLocation(), diag::err_non_variable_decl_in_for);
+ if (D->getNextDeclarator())
+ return Diag(D->getLocation(), diag::err_toomany_element_decls);
+ }
+ else
+ FirstType = static_cast<Expr*>(first)->getType();
+ if (!isObjCObjectPointerType(FirstType))
+ Diag(ForLoc, diag::err_selector_element_type,
+ FirstType.getAsString(), First->getSourceRange());
}
- else
- FirstType = static_cast<Expr*>(first)->getType();
- if (!isObjCObjectPointerType(FirstType))
- Diag(ForLoc, diag::err_selector_element_type,
- FirstType.getAsString(), First->getSourceRange());
if (Second) {
DefaultFunctionArrayConversion(Second);
QualType SecondType = Second->getType();
--- /dev/null
+// RUN: clang -fsyntax-only -verify %s
+
+ce MyList // expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}}
+@end
+
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+
+int LOOP();
+
+@implementation MyList (BasicTest) // expected-error {{cannot find interface declaration for 'MyList'}}
+- (void)compilerTestAgainst {
+MyList * el; // expected-error {{use of undeclared identifier 'MyList'}}
+ for (el in @"foo") // expected-error {{use of undeclared identifier 'el'}} \
+ // expected-error {{cannot find interface declaration for 'NSConstantString'}}
+ { LOOP(); }
+}
+@end
+