diff options
Diffstat (limited to 'src/shared/cplusplus/CheckStatement.cpp')
-rw-r--r-- | src/shared/cplusplus/CheckStatement.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp index 0d7bced86e..c93eca0492 100644 --- a/src/shared/cplusplus/CheckStatement.cpp +++ b/src/shared/cplusplus/CheckStatement.cpp @@ -141,6 +141,35 @@ bool CheckStatement::visit(ExpressionStatementAST *ast) return false; } +bool CheckStatement::visit(ForeachStatementAST *ast) +{ + Block *block = control()->newBlock(ast->foreach_token); + block->setStartOffset(tokenAt(ast->firstToken()).offset); + block->setEndOffset(tokenAt(ast->lastToken()).offset); + ast->symbol = block; + _scope->enterSymbol(block); + Scope *previousScope = switchScope(block->members()); + if (ast->type_specifiers && ast->declarator) { + FullySpecifiedType ty = semantic()->check(ast->type_specifiers, _scope); + Name *name = 0; + ty = semantic()->check(ast->declarator, ty, _scope, &name); + unsigned location = ast->declarator->firstToken(); + if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator) + location = core_declarator->firstToken(); + Declaration *decl = control()->newDeclaration(location, name); + decl->setType(ty); + _scope->enterSymbol(decl); + } else { + FullySpecifiedType exprTy = semantic()->check(ast->initializer, _scope); + (void) exprTy; + } + + FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope); + semantic()->check(ast->statement, _scope); + (void) switchScope(previousScope); + return false; +} + bool CheckStatement::visit(ForStatementAST *ast) { Block *block = control()->newBlock(ast->for_token); |