Skip to content

Commit 5babb21

Browse files
authored
Merge pull request #85 from czgdp1807/ptr_03
Ported ``integration_tests/associate_04.f90`` from LFortran and improve LC to compile it
2 parents d85c4b6 + 5f24853 commit 5babb21

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,6 @@ RUN(NAME struct_04.cpp LABELS gcc llvm NOFAST)
215215

216216
RUN(NAME pointer_01.cpp LABELS gcc llvm NOFAST)
217217
RUN(NAME pointer_02.cpp LABELS gcc llvm NOFAST)
218+
RUN(NAME pointer_03.cpp LABELS gcc llvm NOFAST)
218219

219220
RUN(NAME function_01.cpp LABELS gcc llvm NOFAST)

integration_tests/pointer_03.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <iostream>
2+
#include <cmath>
3+
4+
int main() {
5+
6+
float myreal, x, y, theta, a;
7+
x = 0.42;
8+
y = 0.35;
9+
myreal = 9.1;
10+
theta = 1.5;
11+
a = 0.4;
12+
13+
{
14+
#define z -(x*2 + y*2) * cos(theta)
15+
float *v;
16+
v = &myreal;
17+
std::cout << a + z << " " << a - z << " " << *v << std::endl;
18+
*v = *v * 4.6;
19+
}
20+
21+
std::cout << myreal << std::endl;
22+
23+
if (abs(myreal - 41.86) > 1e-5) {
24+
exit(2);
25+
}
26+
27+
return 0;
28+
29+
}

src/lc/clang_ast_to_asr.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,15 +1869,19 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
18691869
}
18701870

18711871
bool TraverseCompoundStmt(clang::CompoundStmt *x) {
1872+
std::map<std::string, std::string> alias;
1873+
scopes.push_back(alias);
18721874
for (auto &s : x->body()) {
18731875
bool is_stmt_created_ = is_stmt_created;
18741876
is_stmt_created = false;
18751877
TraverseStmt(s);
18761878
if( is_stmt_created ) {
18771879
current_body->push_back(al, ASRUtils::STMT(tmp.get()));
1880+
is_stmt_created = false;
18781881
}
1879-
is_stmt_created_ = is_stmt_created;
1882+
is_stmt_created = is_stmt_created_;
18801883
}
1884+
scopes.pop_back();
18811885
return true;
18821886
}
18831887

0 commit comments

Comments
 (0)