[cfe-commits] r45604 - in /cfe/trunk/Sema: Sema.h SemaExprObjC.cpp SemaStmt.cpp

Chris Lattner clattner at apple.com
Fri Jan 4 16:43:02 PST 2008


On Jan 4, 2008, at 3:59 PM, Fariborz Jahanian wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=45604&view=rev
> Log:
> Minor refactoring of foreach's semantics code per Chris's suggetion.

Thanks fariborz, one more thing:

>
> +++ cfe/trunk/Sema/SemaStmt.cpp Fri Jan  4 17:59:09 2008
> @@ -540,15 +540,15 @@
>   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'.
>     for (ScopedDecl *D = DS->getDecl(); D; D = D- 
> >getNextDeclarator()) {
> -      BlockVarDecl *BVD = dyn_cast<BlockVarDecl>(D);
> +      BlockVarDecl *BVD = cast<BlockVarDecl>(D);

I don't think this change is correct.  Will it fail with "for (static  
int *x ..." ?  If it is right, then the check for BVD equaling null is  
dead.

-Chris

>
>       if (BVD && !BVD->hasLocalStorage())
>         BVD = 0;
>       if (BVD == 0)
> -        return Diag(dyn_cast<ScopedDecl>(D)->getLocation(),
> +        return Diag(cast<ScopedDecl>(D)->getLocation(),
>                     diag::err_non_variable_decl_in_for);
>     }
>   }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list