[COMMITTED] a68: fix export and import of flex modes
Jose E. Marchesi
jemarch@gnu.org
Sun Nov 23 23:01:39 GMT 2025
---
gcc/algol68/a68-exports.cc | 16 ++---------
gcc/algol68/a68-imports.cc | 28 +++++++++++--------
gcc/algol68/a68.h | 1 +
gcc/algol68/ga68-exports.pk | 11 ++++----
.../algol68/compile/modules/module9.a68 | 6 ++++
.../algol68/compile/modules/program-9.a68 | 3 ++
6 files changed, 36 insertions(+), 29 deletions(-)
create mode 100644 gcc/testsuite/algol68/compile/modules/module9.a68
create mode 100644 gcc/testsuite/algol68/compile/modules/program-9.a68
diff --git a/gcc/algol68/a68-exports.cc b/gcc/algol68/a68-exports.cc
index 99ac1d200c2..ffbc93ea3c4 100644
--- a/gcc/algol68/a68-exports.cc
+++ b/gcc/algol68/a68-exports.cc
@@ -251,7 +251,7 @@ a68_asm_output_mode (MOID_T *m, const char *module_label)
ASM_LABEL (m) = (char *) xmalloc (100);
ASM_GENERATE_INTERNAL_LABEL (ASM_LABEL (m), "M", cnt++);
- if (IS_REF(m))
+ if (IS_REF(m) || IS_FLEX (m))
a68_asm_output_mode (SUB (m), module_label);
else if (m != M_STRING && IS_FLEXETY_ROW (m))
a68_asm_output_mode (SUB (m), module_label);
@@ -308,13 +308,6 @@ a68_asm_output_mode (MOID_T *m, const char *module_label)
dw2_asm_output_data (1, GA68_MODE_CMPL, "compl");
dw2_asm_output_data (1, dim, "sizety");
}
- else if (m == M_FLEX_ROW_CHAR)
- {
- dw2_asm_output_data (1, GA68_MODE_ROW, "string");
- dw2_asm_output_data (1, 1, "flex");
- dw2_asm_output_data (1, 1, "dim");
- dw2_asm_output_delta (PTR_SIZE, ASM_LABEL (M_CHAR), module_label, "row of char");
- }
else if (IS_REF (m))
{
dw2_asm_output_data (1, GA68_MODE_NAME, "ref");
@@ -322,15 +315,12 @@ a68_asm_output_mode (MOID_T *m, const char *module_label)
}
else if (IS_FLEX (m))
{
- dw2_asm_output_data (1, GA68_MODE_ROW, "row");
- dw2_asm_output_data (1, 1, "flex");
- dw2_asm_output_data (1, DIM (SUB (m)), "dim");
- dw2_asm_output_delta (PTR_SIZE, ASM_LABEL (SUB (SUB (m))), module_label, "row of");
+ dw2_asm_output_data (1, GA68_MODE_FLEX, "flex");
+ dw2_asm_output_delta (PTR_SIZE, ASM_LABEL (SUB (m)), module_label, "flexible row mode");
}
else if (IS_ROW (m))
{
dw2_asm_output_data (1, GA68_MODE_ROW, "row");
- dw2_asm_output_data (1, 0, "flex");
dw2_asm_output_data (1, DIM (m), "dim");
/* XXX for now emit zeroes as triplets. */
for (int i = 0; i < DIM (m); ++i)
diff --git a/gcc/algol68/a68-imports.cc b/gcc/algol68/a68-imports.cc
index 35061d58df2..2db897dd27c 100644
--- a/gcc/algol68/a68-imports.cc
+++ b/gcc/algol68/a68-imports.cc
@@ -481,7 +481,11 @@ struct encoded_mode
struct
{
- uint8_t flex;
+ uint8_t sub_offset;
+ } flex;
+
+ struct
+ {
uint8_t ndims;
struct encoded_triplet *triplets;
uint64_t sub_offset;
@@ -617,8 +621,10 @@ complete_encoded_mode (encoded_modes_map_t &encoded_modes, uint64_t offset)
}
break;
case GA68_MODE_NAME:
+ case GA68_MODE_FLEX:
/* For recursive declarations. */
- em->moid = a68_create_mode (REF_SYMBOL, 0, NO_NODE, M_ERROR, NO_PACK);
+ em->moid = a68_create_mode (em->kind == GA68_MODE_NAME ? REF_SYMBOL : FLEX_SYMBOL,
+ 0, NO_NODE, M_ERROR, NO_PACK);
sub = complete_encoded_mode (encoded_modes, em->data.name.sub_offset);
if (sub == NO_MOID)
{
@@ -639,11 +645,6 @@ complete_encoded_mode (encoded_modes_map_t &encoded_modes, uint64_t offset)
}
SUB (em->moid) = sub;
DIM (em->moid) = em->data.row.ndims;
- if (em->data.row.flex)
- {
- // XXX we need to add the referred em->moid somewhere.
- em->moid = a68_create_mode (FLEX_SYMBOL, 0, NO_NODE, em->moid, NO_PACK);
- }
break;
case GA68_MODE_STRUCT:
/* For recursive declarations. */
@@ -759,6 +760,10 @@ dump_encoded_mode (struct encoded_mode *em)
printf (" %s : [%" PRIu64 "]\n",
em->data.sct.fields[i].name, em->data.sct.fields[i].mode_offset);
break;
+ case GA68_MODE_FLEX:
+ printf (" flex\n");
+ printf (" sub: %" PRIu64 "\n", em->data.name.sub_offset);
+ break;
case GA68_MODE_UNION:
printf (" union\n");
printf (" nmodes: %" PRIu8 "\n", em->data.union_.nmodes);
@@ -778,7 +783,6 @@ dump_encoded_mode (struct encoded_mode *em)
break;
case GA68_MODE_ROW:
printf (" row\n");
- printf (" flex: %" PRIu8 "\n", em->data.row.flex);
printf (" ndims: %" PRIu8 "\n", em->data.row.ndims);
for (uint8_t i = 0; i < em->data.row.ndims; i++)
{
@@ -842,7 +846,7 @@ a68_decode_modes (MOIF_T *moif, encoded_modes_map_t &encoded_modes,
while (pos < mode_table_end)
{
int8_t sizety;
- uint8_t flex, ndims, nmodes, nargs;
+ uint8_t ndims, nmodes, nargs;
uint16_t nfields;
uint64_t mode_offset = pos;
uint64_t sub, ret_mode_offset;
@@ -873,8 +877,11 @@ a68_decode_modes (MOIF_T *moif, encoded_modes_map_t &encoded_modes,
DOFFSET (sub);
encoded_mode->data.name.sub_offset = sub;
break;
+ case GA68_MODE_FLEX:
+ DOFFSET (sub);
+ encoded_mode->data.flex.sub_offset = sub;
+ break;
case GA68_MODE_ROW:
- DUINT8 (flex);
DUINT8 (ndims);
encoded_mode->data.row.triplets
= (struct encoded_triplet *) xmalloc (sizeof (struct encoded_triplet) * ndims);
@@ -887,7 +894,6 @@ a68_decode_modes (MOIF_T *moif, encoded_modes_map_t &encoded_modes,
encoded_mode->data.row.triplets[i].ub = ub;
}
DOFFSET (sub);
- encoded_mode->data.row.flex = flex;
encoded_mode->data.row.ndims = ndims;
encoded_mode->data.row.sub_offset = sub;
break;
diff --git a/gcc/algol68/a68.h b/gcc/algol68/a68.h
index c6a62e1aa70..6f8fb42cbe3 100644
--- a/gcc/algol68/a68.h
+++ b/gcc/algol68/a68.h
@@ -95,6 +95,7 @@ enum
#define GA68_MODE_NAME 12
#define GA68_MODE_PROC 13
#define GA68_MODE_STRING 14
+#define GA68_MODE_FLEX 15
#define GA68_EXTRACT_MODU 0
#define GA68_EXTRACT_IDEN 1
diff --git a/gcc/algol68/ga68-exports.pk b/gcc/algol68/ga68-exports.pk
index bba1a09c4d2..86484b8d889 100644
--- a/gcc/algol68/ga68-exports.pk
+++ b/gcc/algol68/ga68-exports.pk
@@ -132,7 +132,8 @@ var GA68_MODE_UNKNOWN = 0UB,
GA68_MODE_UNION = 11UB,
GA68_MODE_NAME = 12UB,
GA68_MODE_PROC = 13UB,
- GA68_MODE_STRING = 14UB;
+ GA68_MODE_STRING = 14UB,
+ GA68_MODE_FLEX = 15UB;
type ga68_mode =
struct
@@ -142,7 +143,8 @@ type ga68_mode =
GA68_MODE_BYTES, GA68_MODE_CHAR,
GA68_MODE_CMPL, GA68_MODE_ROW,
GA68_MODE_STRUCT, GA68_MODE_UNION,
- GA68_MODE_NAME, GA68_MODE_PROC];
+ GA68_MODE_NAME, GA68_MODE_PROC,
+ GA68_MODE_FLEX];
union
{
@@ -152,13 +154,12 @@ type ga68_mode =
struct
{
ga68_data_reloc mode;
- } name : kind == GA68_MODE_NAME;
+ } name : kind == GA68_MODE_NAME || kind == GA68_MODE_FLEX;
struct
{
type triplet = struct { ga68_text_reloc lb; ga68_text_reloc ub; };
- uint<8> flex;
uint<8> ndims;
triplet[ndims] dims;
ga68_data_reloc row_of;
@@ -255,7 +256,7 @@ type ga68_extract =
ga68_str opname;
uint<8> prio;
} prio;
-
+
struct
{
uint<8> mark : mark == GA68_EXTRACT_OPER;
diff --git a/gcc/testsuite/algol68/compile/modules/module9.a68 b/gcc/testsuite/algol68/compile/modules/module9.a68
new file mode 100644
index 00000000000..55afd6fef75
--- /dev/null
+++ b/gcc/testsuite/algol68/compile/modules/module9.a68
@@ -0,0 +1,6 @@
+module Module_9 =
+def
+ pub mode Foo = struct (flex[1:0]Event events);
+ pub mode Event = int;
+ skip
+fed
diff --git a/gcc/testsuite/algol68/compile/modules/program-9.a68 b/gcc/testsuite/algol68/compile/modules/program-9.a68
new file mode 100644
index 00000000000..585607ae36b
--- /dev/null
+++ b/gcc/testsuite/algol68/compile/modules/program-9.a68
@@ -0,0 +1,3 @@
+{ dg-modules "module9" }
+
+access Module_9 (skip)
--
2.30.2
More information about the Algol68
mailing list