From 79e029a41825f533bb87b4bee5427b90b62175ae Mon Sep 17 00:00:00 2001 From: Gaius Mulley Date: Sun, 28 Jul 2024 19:20:43 +0100 Subject: [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. Signed-off-by: Gaius Mulley --- gcc/m2/gm2-gcc/m2builtins.cc | 4 ++-- .../gm2/builtins/run/pass/testisnormal.def | 5 ++++ .../gm2/builtins/run/pass/testisnormal.mod | 2 +- .../gm2/builtins/run/pass/testsinl.def | 5 ++++ .../gm2/builtins/run/pass/testsinl.mod | 23 +++++++++++++++++++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gm2/builtins/run/pass/testisnormal.def create mode 100644 gcc/testsuite/gm2/builtins/run/pass/testsinl.def create mode 100644 gcc/testsuite/gm2/builtins/run/pass/testsinl.mod diff --git a/gcc/m2/gm2-gcc/m2builtins.cc b/gcc/m2/gm2-gcc/m2builtins.cc index e3e55a69991..44f48fc01ba 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 00000000000..df01cc353eb --- /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 6b65a7b9b12..1349d80e8e8 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 00000000000..7afd3cc8623 --- /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 00000000000..7f669f89c8e --- /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.