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'.
- BlockVarDecl *BVD = cast<BlockVarDecl>(DS->getDecl());
+ 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();
"collection expression is not of valid object type (its type is '%0')")
DIAG(err_selector_element_type, ERROR,
"selector element is not of valid object type (its type is '%0')")
+DIAG(err_toomany_element_decls, ERROR,
+ "Only one element declaration is allowed")
//===----------------------------------------------------------------------===//
// Semantic Analysis
--- /dev/null
+// RUN: clang -fsyntax-only -verify %s
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+@protocol P @end
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ static i;
+ for (id el, elem in self) // expected-error {{Only one element declaration is allowed}}
+ ++i;
+ for (id el in self)
+ ++i;
+ MyList<P> ***p;
+ for (p in self)
+ ++i;
+
+}
+@end
+