From patchwork Wed Jan 11 09:18:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 41854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3214773wrt; Wed, 11 Jan 2023 01:19:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXvLnACbk5lrHh501n7v93+BIgI/nQBApmQy/E/eBCsTfQhMDUCXzClrhTp09gajxaY0a5p8 X-Received: by 2002:a17:906:d788:b0:7c0:e5c6:2a6d with SMTP id pj8-20020a170906d78800b007c0e5c62a6dmr62948699ejb.39.1673428744697; Wed, 11 Jan 2023 01:19:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673428744; cv=none; d=google.com; s=arc-20160816; b=wcyoUOb2gM1D9uoOAJvhI9TuiyGye+reXnUgdWLS0QIDCXCtWLGh3DLEq7GPD9N3Iw oXbA8ZVhtqGwYOktSk+ZaruqTnyLEi2nexmm3PhS3qk0+bNB6b/5vBI/3PloyIhCTt/W jKYTGqtJb0A6HCtgM5R3ZjnW9lxqZui49SdXhLqEy6UZMLPaT7oWbiK63ZSlUv4faEJ7 ml6vOwHVkeogrsgRHpIZJ74WEls/+nKNft4jsL4uGLj2x1F1OCeP4kpr0ok6Dwo6aE+E Rhcz1XwWksqv6xp5EK8qNsQj9945EVhtqdWEBoesDT3r4HQEeh0aUGUeItlHY7MbeoeE i1Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:content-disposition:mime-version :message-id:subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=m9EzU4MiIpcpz1cu7mwZ4gQRJT/eFLXt5AqAWCP+iiI=; b=AMP9sFFnV9mkLr7+NMjGZyGBNt4+ypKIQjLuRqoQhHCFpVmVgm3Jppps5SMXsNpjIU we8mrKQ87EGZOKit4IwrHTSRbpeCwjfFav5qLOaYXgfLjjjfH9Zqmt5KhJJESff8ojZ7 GeZ1b3Oa5dK/5D4ThN6HALnVUnUhhAiXuqo1po0IyzGsa26EygZ7K1v6hL8oQPIg+tyE Dm2uLKqxnoMdATg2TU+30NIANO8HpRiA4+5FeuhMkq01xJaLug+hxQsBDX9tsBJj6GU7 i5zrk6NWX6b2EzZQPgpJh/CmYBBVuYNFbTJ6vGi0aVqB4x/10PpozlcS9FqQDk/M6nMn VHBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=V88XWHfr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dz17-20020a0564021d5100b0047bb02c3cefsi16957165edb.265.2023.01.11.01.19.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 01:19:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=V88XWHfr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC8783858C5E for ; Wed, 11 Jan 2023 09:19:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC8783858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673428743; bh=m9EzU4MiIpcpz1cu7mwZ4gQRJT/eFLXt5AqAWCP+iiI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=V88XWHfrqWRSEstO0rET4HASLDQFvXbI87rkNroT2JTJNkGVRKgHb+nOAYNYnoBet SQzogzxZXHHbXwkvIk0fyX3/4vqprIidG0VwICdScOUoMieWd9VHuB6k+cAQXcl1XS JS53hOxJsSG+Xw5OQUeFSGz49oIxsfIU9tTEiNlg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 63D6D3858C83 for ; Wed, 11 Jan 2023 09:18:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63D6D3858C83 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-218-N1Lz0ZfeNOmxl8lyuX1mcg-1; Wed, 11 Jan 2023 04:18:17 -0500 X-MC-Unique: N1Lz0ZfeNOmxl8lyuX1mcg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3346101A52E; Wed, 11 Jan 2023 09:18:17 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6012E492B00; Wed, 11 Jan 2023 09:18:17 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30B9IEZu1300253 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 11 Jan 2023 10:18:14 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30B9IEG31300252; Wed, 11 Jan 2023 10:18:14 +0100 Date: Wed, 11 Jan 2023 10:18:13 +0100 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] fortran: Fix up function types for realloc and sincos{,f,l} builtins [PR108349] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754717219287838410?= X-GMAIL-MSGID: =?utf-8?q?1754717219287838410?= Hi! 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. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-01-11 Jakub Jelinek PR fortran/108349 * f95-lang.cc (gfc_init_builtin_function): Fix up function types for BUILT_IN_REALLOC and BUILT_IN_SINCOS{F,,L}. Formatting fixes. Jakub --- gcc/fortran/f95-lang.cc.jj 2022-11-15 22:57:18.247210671 +0100 +++ gcc/fortran/f95-lang.cc 2023-01-10 11:31:43.787266346 +0100 @@ -714,31 +714,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_longdouble_clongdouble = - build_function_type_list (complex_long_double_type_node, - 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); 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) @@ -992,9 +995,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);