]> granicus.if.org Git - clang/commitdiff
twiks based on Chris's comment. No need to iterate thru a list of declarations
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 5 Jan 2008 01:40:08 +0000 (01:40 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 5 Jan 2008 01:40:08 +0000 (01:40 +0000)
in a foreach-statement which is illegal (but not yet caught) .

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45615 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaStmt.cpp

index 81eb0b0060f26b8f05e91e437b47cc2d7c165225..ab40e708e3663e976ffecf65676dff429886c12c 100644 (file)
@@ -543,14 +543,9 @@ Sema::ActOnObjcForCollectionStmt(SourceLocation ForColLoc,
     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'.
-    for (ScopedDecl *D = DS->getDecl(); D; D = D->getNextDeclarator()) {
-      BlockVarDecl *BVD = cast<BlockVarDecl>(D);
-      if (BVD && !BVD->hasLocalStorage())
-        BVD = 0;
-      if (BVD == 0)
-        return Diag(cast<ScopedDecl>(D)->getLocation(), 
-                    diag::err_non_variable_decl_in_for);
-    }
+    BlockVarDecl *BVD = cast<BlockVarDecl>(DS->getDecl());
+    if (!BVD->hasLocalStorage())
+      return Diag(BVD->getLocation(), diag::err_non_variable_decl_in_for);
   }
   else
     FirstType = static_cast<Expr*>(first)->getType();