From 2318961b7ad3572a7110be1ee27c8fd082db4a03 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Sat, 3 Feb 2024 01:12:13 +0530 Subject: [PATCH 1/3] DEV: Always alias in CompountStmt node --- src/lc/clang_ast_to_asr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; } From d3dc6a842dcc4871eefae0f0d15931e0776e5072 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Sat, 3 Feb 2024 01:13:58 +0530 Subject: [PATCH 2/3] TEST: Ported integration_tests/associate_04.f90 from LFortran --- integration_tests/pointer_03.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 integration_tests/pointer_03.cpp 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; + +} From 5f24853b45531fd2a1c48b5db12fd8b0f8c03478 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Sat, 3 Feb 2024 01:14:18 +0530 Subject: [PATCH 3/3] TEST: Register pointer_03.cpp --- integration_tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) 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)