https://gcc.gnu.org/g:056448490e4ddb03263d9566b8aaee2340cba3ac

commit r14-10986-g056448490e4ddb03263d9566b8aaee2340cba3ac
Author: Gaius Mulley <gaiusm...@gmail.com>
Date:   Tue Nov 26 13:18:27 2024 +0000

    [PATCH] PR modula2/115823 Wrong expansion of isnormal optab
    
    This patch corrects the function declaration of a builtin
    (using the libname rather than the source name).
    
    gcc/m2/ChangeLog:
    
            PR modula2/115823
            * gm2-gcc/m2builtins.cc (define_builtin): Build
            the function decl using the libname.
    
    gcc/testsuite/ChangeLog:
    
            PR modula2/115823
            * gm2/builtins/run/pass/testisnormal.mod: Change to an
            implementation module.
            * gm2/builtins/run/pass/testisnormal.def: New test.
            * gm2/builtins/run/pass/testsinl.def: New test.
            * gm2/builtins/run/pass/testsinl.mod: New test.
    
    (cherry picked from commit 79e029a41825f533bb87b4bee5427b90b62175ae)
    
    Signed-off-by: Gaius Mulley <gaiusm...@gmail.com>

Diff:
---
 gcc/m2/gm2-gcc/m2builtins.cc                       |  4 ++--
 .../gm2/builtins/run/pass/testisnormal.def         |  5 +++++
 .../gm2/builtins/run/pass/testisnormal.mod         |  2 +-
 gcc/testsuite/gm2/builtins/run/pass/testsinl.def   |  5 +++++
 gcc/testsuite/gm2/builtins/run/pass/testsinl.mod   | 23 ++++++++++++++++++++++
 5 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/gcc/m2/gm2-gcc/m2builtins.cc b/gcc/m2/gm2-gcc/m2builtins.cc
index e3e55a699917..44f48fc01ba8 100644
--- a/gcc/m2/gm2-gcc/m2builtins.cc
+++ b/gcc/m2/gm2-gcc/m2builtins.cc
@@ -1431,8 +1431,8 @@ define_builtin (enum built_in_function val, const char 
*name, tree prototype,
   tree decl;
   builtin_macro_definition bmd;
 
-  decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, get_identifier (name),
-                     prototype);
+  decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
+                    get_identifier (libname), prototype);
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
   SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testisnormal.def 
b/gcc/testsuite/gm2/builtins/run/pass/testisnormal.def
new file mode 100644
index 000000000000..df01cc353eb5
--- /dev/null
+++ b/gcc/testsuite/gm2/builtins/run/pass/testisnormal.def
@@ -0,0 +1,5 @@
+DEFINITION MODULE testisnormal ;
+
+PROCEDURE test ;
+
+END testisnormal.
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testisnormal.mod 
b/gcc/testsuite/gm2/builtins/run/pass/testisnormal.mod
index 6b65a7b9b122..1349d80e8e8e 100644
--- a/gcc/testsuite/gm2/builtins/run/pass/testisnormal.mod
+++ b/gcc/testsuite/gm2/builtins/run/pass/testisnormal.mod
@@ -1,4 +1,4 @@
-MODULE testisnormal ;
+IMPLEMENTATION MODULE testisnormal ;
 
 FROM libc IMPORT printf, exit ;
 FROM Builtins IMPORT isnormal ;
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testsinl.def 
b/gcc/testsuite/gm2/builtins/run/pass/testsinl.def
new file mode 100644
index 000000000000..7afd3cc86235
--- /dev/null
+++ b/gcc/testsuite/gm2/builtins/run/pass/testsinl.def
@@ -0,0 +1,5 @@
+DEFINITION MODULE testsinl ;
+
+PROCEDURE test ;
+
+END testsinl.
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testsinl.mod 
b/gcc/testsuite/gm2/builtins/run/pass/testsinl.mod
new file mode 100644
index 000000000000..7f669f89c8e2
--- /dev/null
+++ b/gcc/testsuite/gm2/builtins/run/pass/testsinl.mod
@@ -0,0 +1,23 @@
+IMPLEMENTATION MODULE testsinl ;
+
+FROM libc IMPORT printf ;
+FROM Builtins IMPORT sinl ;
+
+
+(*
+   test -
+*)
+
+PROCEDURE test ;
+VAR
+   result: LONGREAL ;
+BEGIN
+   result := sinl (3.14) ;
+   printf ("sinl (3.14) = %lg\n", result) ;
+END test ;
+
+
+BEGIN
+   test ;
+   printf ("all tests pass\n")
+END testsinl.

Reply via email to