From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 49D823858C5E for ; Wed, 11 Jan 2023 09:18:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49D823858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673428701; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m9EzU4MiIpcpz1cu7mwZ4gQRJT/eFLXt5AqAWCP+iiI=; b=EzNk3IlWywpHi5w4nrJFFp2n0B6QKGrtW05pZqHD7Z618IJaqhTiYMEPwT1zTDwIYv8lVS u/Kr1ocecZ9DsqofVsOgWS6uF9Ape+QHyuG/S5sZojJl/jliFjnNCY4+fZeAPwSpcovOuX BC/3Nky8ZWTZq7nCJVlKTP+aKcuP6Og= 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 From: Jakub Jelinek 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: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- 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); Jakub