Skip to content

Commit 054b93f

Browse files
committed
Update references
1 parent 20677d0 commit 054b93f

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "c-structs_33-4a3339f",
3+
"cmd": "lpython --no-color --show-c {infile}",
4+
"infile": "tests/../integration_tests/structs_33.py",
5+
"infile_hash": "15fdcb483c864b6322ebcf6c495e635bbe917f1d8b407ccf4dc3e2ee",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": "c-structs_33-4a3339f.stdout",
9+
"stdout_hash": "425a22068f547e15ba187e2974220f28f0af3a70305b67cfd4a6a655",
10+
"stderr": null,
11+
"stderr_hash": null,
12+
"returncode": 0
13+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include <inttypes.h>
2+
3+
#include <stdlib.h>
4+
#include <stdbool.h>
5+
#include <stdio.h>
6+
#include <string.h>
7+
#include <lfortran_intrinsics.h>
8+
9+
struct dimension_descriptor
10+
{
11+
int32_t lower_bound, length;
12+
};
13+
struct __attribute__((packed)) inner_struct {
14+
int32_t inner_field;
15+
};
16+
17+
struct __attribute__((packed)) outer_struct {
18+
struct inner_struct inner_s;
19+
};
20+
21+
22+
inline void struct_deepcopy_outer_struct(struct outer_struct* src, struct outer_struct* dest);
23+
inline void struct_deepcopy_inner_struct(struct inner_struct* src, struct inner_struct* dest);
24+
25+
26+
// Implementations
27+
void check()
28+
{
29+
struct inner_struct inner_struct_instance_value;
30+
struct inner_struct* inner_struct_instance = &inner_struct_instance_value;
31+
struct outer_struct outer_struct_instance_value;
32+
struct outer_struct* outer_struct_instance = &outer_struct_instance_value;
33+
struct outer_struct outer_struct_instance2_value;
34+
struct outer_struct* outer_struct_instance2 = &outer_struct_instance2_value;
35+
outer_struct_instance->inner_s.inner_field = 5;
36+
struct_deepcopy_outer_struct(outer_struct_instance, outer_struct_instance2);
37+
struct_deepcopy_inner_struct(&outer_struct_instance2->inner_s, inner_struct_instance);
38+
ASSERT(inner_struct_instance->inner_field == 5);
39+
}
40+
41+
void _lpython_main_program()
42+
{
43+
check();
44+
}
45+
46+
int main(int argc, char* argv[])
47+
{
48+
_lpython_set_argv(argc, argv);
49+
_lpython_main_program();
50+
return 0;
51+
}
52+
53+
void struct_deepcopy_inner_struct(struct inner_struct* src, struct inner_struct* dest) {
54+
dest->inner_field = src->inner_field;
55+
}
56+
57+
void struct_deepcopy_outer_struct(struct outer_struct* src, struct outer_struct* dest) {
58+
struct_deepcopy_inner_struct(&(src->inner_s), &(dest->inner_s));;
59+
}
60+
61+

tests/tests.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ asr = true
337337
filename = "../integration_tests/structs_05.py"
338338
asr = true
339339

340+
[[test]]
341+
filename = "../integration_tests/structs_33.py"
342+
c = true
343+
340344
[[test]]
341345
filename = "../integration_tests/callback_01.py"
342346
asr = true

0 commit comments

Comments
 (0)