https://gcc.gnu.org/g:3e9d5caf6c7d79d2e77c903477680149095c1b7b

commit r17-4587-g3e9d5caf6c7d79d2e77c903477680149095c1b7b
Author: Jose E. Marchesi <[email protected]>
Date:   Wed Sep 23 01:07:09 2026 +0200

    a68: mark module {pre,post}lude functions as artificial
    
    When lowering a module-text two functions are synthesized: the one
    corresponding to the module's prelude and the one corresponding to the
    module's postlude.  These declarations are artificial and need to be
    marke as such by setting DECL_ARTIFICIAL to 1.
    
    Signed-off-by: Jose E. Marchesi <[email protected]>
    
    gcc/algol68/ChangeLog
    
            * a68-low.cc (lower_module_text): Mark prelude_decl an
            postlude_decl as artificial.
    
    gcc/testsuite/ChangeLog
    
            * algol68/compile/prepostlude-crash-1.a68: New test.

Diff:
---
 gcc/algol68/a68-low.cc                                |  2 ++
 gcc/testsuite/algol68/compile/prepostlude-crash-1.a68 | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/gcc/algol68/a68-low.cc b/gcc/algol68/a68-low.cc
index 8fc112cd76f6..62fbdc49d3fa 100644
--- a/gcc/algol68/a68-low.cc
+++ b/gcc/algol68/a68-low.cc
@@ -1318,6 +1318,7 @@ lower_module_text (NODE_T *p, LOW_CTX_T ctx)
   DECL_EXTERNAL (prelude_decl) = 0;
   TREE_PUBLIC (prelude_decl) = 1;
   TREE_STATIC (prelude_decl) = 1;
+  DECL_ARTIFICIAL (prelude_decl) = 1;
 
   a68_push_function_range (prelude_decl,
                           void_type_node /* result_type */, true /* top_level 
*/);
@@ -1376,6 +1377,7 @@ lower_module_text (NODE_T *p, LOW_CTX_T ctx)
   DECL_EXTERNAL (postlude_decl) = 0;
   TREE_PUBLIC (postlude_decl) = 1;
   TREE_STATIC (postlude_decl) = 1;
+  DECL_ARTIFICIAL (postlude_decl) = 1;
 
   a68_push_function_range (postlude_decl,
                           void_type_node /* result_type */, true /* top_level 
*/);
diff --git a/gcc/testsuite/algol68/compile/prepostlude-crash-1.a68 
b/gcc/testsuite/algol68/compile/prepostlude-crash-1.a68
new file mode 100644
index 000000000000..c686dde1f776
--- /dev/null
+++ b/gcc/testsuite/algol68/compile/prepostlude-crash-1.a68
@@ -0,0 +1,16 @@
+{ This program triggers the gcc_assert at dwarf2out.cc:31161 unless
+  the prelude and postlude functions of the module are marked with
+  DECL_ARTIFICIAL.  This happens only with -O2 and I am not sure why
+  this happens (it is related to the fact the synthesized prelude
+  function is the parent of the resulting typedef that defines
+  CPNM_value). }
+
+module CPNMA68 = def
+
+     mode CPNM_value = real;
+
+     pub proc cpnm_export_value = (real value) int:
+        skip;
+
+     skip
+fed

Reply via email to