public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-10698] fortran: Fix up function types for realloc and sincos{, f, l} builtins [PR108349]
Date: Tue,  2 May 2023 20:13:31 +0000 (GMT)	[thread overview]
Message-ID: <20230502201331.8EB753881D21@sourceware.org> (raw)

https://gcc.gnu.org/g:d67efd5a4ff7ef0992c641b04b009195d872f7bd

commit r11-10698-gd67efd5a4ff7ef0992c641b04b009195d872f7bd
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 11 10:40:54 2023 +0100

    fortran: Fix up function types for realloc and sincos{,f,l} builtins [PR108349]
    
    As reported in the PR, the FUNCTION_TYPE for __builtin_realloc in the
    Fortran FE is wrong since r0-100026-gb64fca63690ad which changed
    -  tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node);
    -  tmp = tree_cons (NULL_TREE, size_type_node, tmp);
    -  ftype = build_function_type (pvoid_type_node, tmp);
    +  ftype = build_function_type_list (pvoid_type_node,
    +                                    size_type_node, pvoid_type_node,
    +                                    NULL_TREE);
       gfc_define_builtin ("__builtin_realloc", ftype, BUILT_IN_REALLOC,
                          "realloc", false);
    The return type is correct, void *, but the first argument should be
    void * too and only second one size_t, while the above change changed
    realloc to be void *__builtin_realloc (size_t, void *);
    I went through all other changes from that commit and found that
    __builtin_sincos{,f,l} got broken as well, instead of the former
    void __builtin_sincos{,f,l} (ftype, ftype *, ftype *);
    where ftype is {double,float,long double} it is now incorrectly
    void __builtin_sincos{,f,l} (ftype *, ftype *);
    
    The following patch fixes that, plus some formatting issues around
    the spots I've changed.
    
    2023-01-11  Jakub Jelinek  <jakub@redhat.com>
    
            PR fortran/108349
            * f95-lang.c (gfc_init_builtin_function): Fix up function types
            for BUILT_IN_REALLOC and BUILT_IN_SINCOS{F,,L}.  Formatting fixes.
    
    (cherry picked from commit 0986c351aa8a9f08b3cb614baec13564dd62c114)

Diff:
---
 gcc/fortran/f95-lang.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index a346457b5e0..b11cff6559b 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -696,31 +696,34 @@ gfc_init_builtin_functions (void)
                                                 float_type_node, NULL_TREE);
 
   func_cdouble_double = build_function_type_list (double_type_node,
-                                                  complex_double_type_node,
-                                                  NULL_TREE);
+						  complex_double_type_node,
+						  NULL_TREE);
 
   func_double_cdouble = build_function_type_list (complex_double_type_node,
-                                                  double_type_node, NULL_TREE);
+						  double_type_node, NULL_TREE);
 
-  func_clongdouble_longdouble =
-    build_function_type_list (long_double_type_node,
-                              complex_long_double_type_node, NULL_TREE);
+  func_clongdouble_longdouble
+    = build_function_type_list (long_double_type_node,
+				complex_long_double_type_node, NULL_TREE);
 
-  func_longdouble_clongdouble =
-    build_function_type_list (complex_long_double_type_node,
-                              long_double_type_node, NULL_TREE);
+  func_longdouble_clongdouble
+    = build_function_type_list (complex_long_double_type_node,
+				long_double_type_node, NULL_TREE);
 
   ptype = build_pointer_type (float_type_node);
-  func_float_floatp_floatp =
-    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);
+  func_float_floatp_floatp
+    = build_function_type_list (void_type_node, float_type_node, ptype, ptype,
+				NULL_TREE);
 
   ptype = build_pointer_type (double_type_node);
-  func_double_doublep_doublep =
-    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);
+  func_double_doublep_doublep
+    = build_function_type_list (void_type_node, double_type_node, ptype,
+				ptype, NULL_TREE);
 
   ptype = build_pointer_type (long_double_type_node);
-  func_longdouble_longdoublep_longdoublep =
-    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);
+  func_longdouble_longdoublep_longdoublep
+    = build_function_type_list (void_type_node, long_double_type_node, ptype,
+				ptype, NULL_TREE);
 
 /* Non-math builtins are defined manually, so they're not included here.  */
 #define OTHER_BUILTIN(ID,NAME,TYPE,CONST)
@@ -974,9 +977,8 @@ gfc_init_builtin_functions (void)
 		      "calloc", ATTR_NOTHROW_LEAF_MALLOC_LIST);
   DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_CALLOC)) = 1;
 
-  ftype = build_function_type_list (pvoid_type_node,
-                                    size_type_node, pvoid_type_node,
-                                    NULL_TREE);
+  ftype = build_function_type_list (pvoid_type_node, pvoid_type_node,
+				    size_type_node, NULL_TREE);
   gfc_define_builtin ("__builtin_realloc", ftype, BUILT_IN_REALLOC,
 		      "realloc", ATTR_NOTHROW_LEAF_LIST);

                 reply	other threads:[~2023-05-02 20:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230502201331.8EB753881D21@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).