diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 8e8fe27..a7af3af 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -215,5 +215,6 @@ RUN(NAME struct_04.cpp LABELS gcc llvm NOFAST) RUN(NAME pointer_01.cpp LABELS gcc llvm NOFAST) RUN(NAME pointer_02.cpp LABELS gcc llvm NOFAST) +RUN(NAME pointer_03.cpp LABELS gcc llvm NOFAST) RUN(NAME function_01.cpp LABELS gcc llvm NOFAST) diff --git a/integration_tests/pointer_03.cpp b/integration_tests/pointer_03.cpp new file mode 100644 index 0000000..92decd4 --- /dev/null +++ b/integration_tests/pointer_03.cpp @@ -0,0 +1,29 @@ +#include +#include + +int main() { + + float myreal, x, y, theta, a; + x = 0.42; + y = 0.35; + myreal = 9.1; + theta = 1.5; + a = 0.4; + + { + #define z -(x*2 + y*2) * cos(theta) + float *v; + v = &myreal; + std::cout << a + z << " " << a - z << " " << *v << std::endl; + *v = *v * 4.6; + } + + std::cout << myreal << std::endl; + + if (abs(myreal - 41.86) > 1e-5) { + exit(2); + } + + return 0; + +} diff --git a/src/lc/clang_ast_to_asr.cpp b/src/lc/clang_ast_to_asr.cpp index ae72ae9..59f4067 100644 --- a/src/lc/clang_ast_to_asr.cpp +++ b/src/lc/clang_ast_to_asr.cpp @@ -1869,15 +1869,19 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor alias; + scopes.push_back(alias); for (auto &s : x->body()) { bool is_stmt_created_ = is_stmt_created; is_stmt_created = false; TraverseStmt(s); if( is_stmt_created ) { current_body->push_back(al, ASRUtils::STMT(tmp.get())); + is_stmt_created = false; } - is_stmt_created_ = is_stmt_created; + is_stmt_created = is_stmt_created_; } + scopes.pop_back(); return true; }