Skip to content

Commit 3913614

Browse files
committed
fix for flang-426805
1 parent f02e9d1 commit 3913614

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

tools/flang2/flang2exe/llutil.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,10 +1876,12 @@ use_gpu_output_file(void)
18761876
{
18771877
set_llasm_output_file(gbl.ompaccfile);
18781878
}
1879+
void reset_write_ftn_typedefs(void);
18791880
void
18801881
use_cpu_output_file(void)
18811882
{
18821883
set_llasm_output_file(gbl.asmfil);
1884+
reset_write_ftn_typedefs();
18831885
}
18841886
#endif
18851887
/**
@@ -3266,6 +3268,21 @@ write_struct_defs(void)
32663268
}
32673269
}
32683270

3271+
void
3272+
set_defs_printed(char *name)
3273+
{
3274+
LLDEF *cur_def;
3275+
int gblsym;
3276+
3277+
cur_def = struct_def_list;
3278+
while (cur_def) {
3279+
if (cur_def->printed == 0 && cur_def->name && !strcmp(name, cur_def->name)) {
3280+
cur_def->printed = 2;
3281+
}
3282+
cur_def = cur_def->next;
3283+
}
3284+
}
3285+
32693286
void
32703287
write_ftn_typedefs(void)
32713288
{
@@ -3274,13 +3291,28 @@ write_ftn_typedefs(void)
32743291

32753292
cur_def = struct_def_list;
32763293
while (cur_def) {
3277-
if (!cur_def->printed && cur_def->name && cur_def->dtype) {
3294+
if (cur_def->name && cur_def->dtype) {
32783295
gblsym = get_typedef_ag(cur_def->name,
32793296
process_dtype_struct(cur_def->dtype));
3280-
if (gblsym == 0) {
3297+
if (cur_def->printed == 0) {
32813298
write_def(cur_def, 0);
32823299
}
3283-
cur_def->printed = 1;
3300+
set_defs_printed(cur_def->name);
3301+
}
3302+
cur_def = cur_def->next;
3303+
}
3304+
}
3305+
3306+
void
3307+
reset_write_ftn_typedefs(void)
3308+
{
3309+
LLDEF *cur_def;
3310+
int gblsym;
3311+
3312+
cur_def = struct_def_list;
3313+
while (cur_def) {
3314+
if (cur_def->name && cur_def->dtype && cur_def->printed == 2) {
3315+
cur_def->printed = 0;
32843316
}
32853317
cur_def = cur_def->next;
32863318
}

0 commit comments

Comments
 (0)