Skip to content

Commit

Permalink
Merge pull request #85 from czgdp1807/ptr_03
Browse files Browse the repository at this point in the history
Ported ``integration_tests/associate_04.f90`` from LFortran and improve LC to compile it
  • Loading branch information
czgdp1807 authored Feb 2, 2024
2 parents d85c4b6 + 5f24853 commit 5babb21
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
29 changes: 29 additions & 0 deletions integration_tests/pointer_03.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#include <cmath>

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;

}
6 changes: 5 additions & 1 deletion src/lc/clang_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,15 +1869,19 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
}

bool TraverseCompoundStmt(clang::CompoundStmt *x) {
std::map<std::string, std::string> 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;
}

Expand Down

0 comments on commit 5babb21

Please sign in to comment.