From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F281E3861018; Thu, 2 Sep 2021 23:42:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F281E3861018 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/100907] Bind(c): failure handling wide character Date: Thu, 02 Sep 2021 23:42:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: patch X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jrfsousa at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Sep 2021 23:42:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100907 --- Comment #8 from CVS Commits --- The master branch has been updated by Sandra Loosemore : https://gcc.gnu.org/g:93b6b2f614eb692d1d8126ec6cb946984a9d01d7 commit r12-3321-g93b6b2f614eb692d1d8126ec6cb946984a9d01d7 Author: Sandra Loosemore Date: Wed Aug 18 07:22:03 2021 -0700 libgfortran: Further fixes for GFC/CFI descriptor conversions. This patch is for: PR100907 - Bind(c): failure handling wide character PR100911 - Bind(c): failure handling C_PTR PR100914 - Bind(c): errors handling complex PR100915 - Bind(c): failure handling C_FUNPTR PR100917 - Bind(c): errors handling long double real All of these problems are related to the GFC descriptors constructed by the Fortran front end containing ambigous or incomplete information. This patch does not attempt to change the GFC data structure or the front end, and only makes the runtime interpret it in more reasonable ways. It's not a complete fix for any of the listed issues. The Fortran front end does not distinguish between C_PTR and C_FUNPTR, mapping both onto BT_VOID. That is what this patch does also. The other bugs are related to GFC descriptors only containing elem_len and not kind. For complex types, the elem_len needs to be divided by 2 and then mapped onto a real kind. On x86 targets, the kind corresponding to C long double is different than its elem_len; since we cannot accurately disambiguate between a 16-byte kind 10 long double from __float128, this patch arbitrarily prefers to interpret tha= t as the standard long double type rather than the GNU extension. Similarly, for character types, the GFC descriptor cannot distinguish between character(kind=3Dc_char, len=3D4) and character(kind=3Ducs4, le= n=3D1). But since the front end currently rejects anything other than len=3D1 (PR92482) this patch uses the latter interpretation. 2021-09-01 Sandra Loosemore Jos=C3=A9 Rui Faustino de Sousa gcc/testsuite/ PR fortran/100911 PR fortran/100915 PR fortran/100916 * gfortran.dg/PR100911.c: New file. * gfortran.dg/PR100911.f90: New file. * gfortran.dg/PR100914.c: New file. * gfortran.dg/PR100914.f90: New file. * gfortran.dg/PR100915.c: New file. * gfortran.dg/PR100915.f90: New file. libgfortran/ PR fortran/100907 PR fortran/100911 PR fortran/100914 PR fortran/100915 PR fortran/100917 * ISO_Fortran_binding-1-tmpl.h (CFI_type_cfunptr): Make equival= ent to CFI_type_cptr. * runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc): Fix handling of CFI_type_cptr and CFI_type_cfunptr. Additional err= or checking and code cleanup. (gfc_desc_to_cfi_desc): Likewise. Also correct kind mapping for character, complex, and long double types.=