File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,19 @@ def f(c: CPtr):
18
18
print (A )
19
19
assert A == 3
20
20
21
+ def g (c : CPtr ):
22
+ i : i32
23
+ for i in range (3 ):
24
+ p : Pointer [S ] = c_p_pointer (c , S )
25
+ A : i32 = p .a
26
+ print (A )
27
+ assert A == 3
28
+
21
29
def main ():
22
30
s : S = S (3 )
23
31
p : CPtr = empty_c_void_p ()
24
32
p_c_pointer (pointer (s , S ), p )
25
33
f (p )
34
+ g (p )
26
35
27
36
main ()
Original file line number Diff line number Diff line change @@ -324,6 +324,8 @@ R"(#include <stdio.h>
324
324
std::string close_paranthesis = indent + " }\n " ;
325
325
indent += std::string (indentation_spaces, ' ' );
326
326
indentation_level += 1 ;
327
+ SymbolTable* current_scope_copy = current_scope;
328
+ current_scope = block->m_symtab ;
327
329
std::vector<std::string> var_order = ASRUtils::determine_variable_declaration_order (block->m_symtab );
328
330
for (auto &item : var_order) {
329
331
ASR::symbol_t * var_sym = block->m_symtab ->get_symbol (item);
@@ -343,6 +345,7 @@ R"(#include <stdio.h>
343
345
decl += check_tmp_buffer ();
344
346
src = open_paranthesis + decl + body + close_paranthesis;
345
347
indentation_level -= 1 ;
348
+ current_scope = current_scope_copy;
346
349
}
347
350
348
351
// Returns the declaration, no semi colon at the end
You can’t perform that action at this time.
0 commit comments