[gcc r16-1345] PR modula2/119779: ASM examples no longer work
Gaius Mulley
gaius@gcc.gnu.org
Mon Jun 9 14:27:14 GMT 2025
https://gcc.gnu.org/g:0adb415d128cf54b607b71f1022bbf088ab6ae36
commit r16-1345-g0adb415d128cf54b607b71f1022bbf088ab6ae36
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Mon Jun 9 15:26:35 2025 +0100
PR modula2/119779: ASM examples no longer work
This patch introduces a regression test using the example in the
documentation and tests it using -masm=intel on x86_64-*-gnu systems.
gcc/testsuite/ChangeLog:
PR modula2/119779
* gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp: New test.
* gm2.dg/doc/examples/run/pass/exampleadd2.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diff:
---
.../examples/run/pass/doc-examples-run-pass.exp | 17 +++++++++++
.../gm2.dg/doc/examples/run/pass/exampleadd2.mod | 35 ++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/gcc/testsuite/gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp b/gcc/testsuite/gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp
new file mode 100644
index 000000000000..6fb7d6e2cf37
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp
@@ -0,0 +1,17 @@
+# Compile tests, no torture testing.
+#
+# These tests should all pass.
+
+# Load support procs.
+load_lib gm2-dg.exp
+
+gm2_init_pim4 $srcdir/$subdir -masm=intel
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] "" ""
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gm2.dg/doc/examples/run/pass/exampleadd2.mod b/gcc/testsuite/gm2.dg/doc/examples/run/pass/exampleadd2.mod
new file mode 100644
index 000000000000..8bab2994c226
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/doc/examples/run/pass/exampleadd2.mod
@@ -0,0 +1,35 @@
+(* { dg-do assemble { target { x86_64-*-gnu* } } } *)
+(* { dg-options "-masm=intel" } *)
+(* { dg-do run { target x86_64-*-gnu* } } *)
+
+MODULE exampleadd2 ;
+
+FROM libc IMPORT printf, exit ;
+
+
+PROCEDURE Example (foo, bar: LONGCARD) : CARDINAL ;
+VAR
+ myout: LONGCARD ;
+BEGIN
+ ASM VOLATILE (
+ "mov rax, %[left]; add rax, %[right]; mov %[output], rax;"
+ : [output] "=rm" (myout) (* outputs *)
+ : [left] "rm" (foo), [right] "rm" (bar) (* inputs *)
+ : "rax") ; (* we trash *)
+ RETURN( myout )
+END Example ;
+
+VAR
+ a, b, c: CARDINAL ;
+BEGIN
+ a := 1 ;
+ b := 2 ;
+ c := Example (a, b) ;
+ IF c = 3
+ THEN
+ printf ("success result from function is %d\n", c) ;
+ ELSE
+ printf ("example failed to return 3, seen %d\n" , c) ;
+ exit (1)
+ END
+END exampleadd2.
\ No newline at end of file
More information about the Gcc-cvs
mailing list