From patchwork Fri Jan 14 20:56:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1580288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=tYYAqcV3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JbDBk68NVz9sSs for ; Sat, 15 Jan 2022 07:57:17 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E4043858403 for ; Fri, 14 Jan 2022 20:57:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E4043858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642193833; bh=w8B5rqAS124tJ8F3Sl29c7brhrSaKBL6cv7WzGUaBiA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tYYAqcV3SxCvk14JPD6tnqPmey4oINyKEF2vxkEsgcvsaxzKU8heOk27MOMce+pJI Kq+ijNti5sqZZ2WDA6jFg3pYd6+1VLnZercwwzEKIkNwL5mmASSKOg79UbkJuaSieo au2UIgqgTrnN8YowdqJ5uh3syDsPAgaJ6f1zOtP8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 9DD5D3858403; Fri, 14 Jan 2022 20:56:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9DD5D3858403 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.84.157] ([93.207.84.157]) by web-mail.gmx.net (3c-app-gmx-bap59.server.lan [172.19.172.129]) (via HTTP); Fri, 14 Jan 2022 21:56:13 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] PR fortran/99256 - ICE in variable_check, at fortran/check.c:1012 Date: Fri, 14 Jan 2022 21:56:13 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:KsBUsJMmK4kBQ7RW4txF3N1f4pDTUjHyib0ZOuve+G84QQO0MasM7V5Vcbnn1XDmiKxD4 ZNNzH9GL0XtaJz8cYz84c5cJ7x84zoCThkYQCIeHZmvnlx1sI8p+34O96m5up2LFxc7Ph1ukuqHf 5YdKfFbZYE4p+ALUfC8Pk3AWmvTbdHVH3ztCMaWPr4Q7B2NdVBlKD26+Dgo/f2+rArPFek8rcpUU Dwlz5LZ1PfAfyD6qvKL8mvOsi8vZHP/+CubCfWImvlxXAq9RKS+niwmlP2BPv29sYMPGM8NaS9Bq 24= X-UI-Out-Filterresults: notjunk:1;V03:K0:A3C11EQbhZA=:JmlSxQLazOk+bMufFN7k58 eIyjWRNeItZ9NtmZ+bufKJrBKMLkcK9X9rdeloUyGXq8XGcg3duNeLSM+4JnY82nL78rE6PyQ gsrMUs4K61r8PGG8IGdlfqvrbTcq0SvHzxOr35tYGeBY+F1D+ny6eY/cgi8ZlyOhknblIMtGq 4Yrvzp/2A3Hwn9ZOeXSdbdUtae9EjCO2KfaSZB0OomMyijbfJuvBxUULi8UKEEA000azc//43 shT1FbC5kiVEi3duEyjotegszqOa7BFE0sMTMmDRgVrV7Hh51Q3kk/U7bnDD3gUp+HZ7RGcs6 aUTAsctqTRhWSYaxFhSO1c6SxmyUgi5LF6Co8BAPVl6pyVcc+eXMTwUl5RZJs2AKUsCIlrAS0 sZoMWctrNW/ED7mbmhAiNTDYQS6kpTJQrC/dibE0bKAUJBlrkimFQ0OJ02LXSMCGXOdcvlx8K iTrobCc2nNWTh9bZeWVr/G2pZ91Xs0/sBoTd2/lb0oBR40cX5UiLhlp1g98YNC4mGZvwgkNkS z7WbzJaXJbsvJ15cbYadc5Xuz90Krrt9MoJFHm9zD+a9Ud4uJr0ppDqxSklA6UY40vqCnwjE7 xob2pINuUsnUKAI7Z812zrmeGXzjSOKKUdF5Y+0Tm44xxEK8S607+t/xZyrRix45oMXxlwDMt ekOx66WIIrwWP4jb5TDnB9yA/mfxXxgAkrvQ8TdHhpONxY+d7rLC5odiOUIN9C7RFbppMo3tF Dc57RBPuX7NJjF5m8E0eOVV+1cHwOf9mnuD07F3/vtEBt2hCHvie47bt31gaJaBN9F8/BhTQg xLipo4M X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Dear all, this is a rather satisfying mini-patch which removes code to fix a bug. The intrinsics MOVE_ALLOC, C_F_POINTER, and C_F_PROCPOINTER require deferred checks of part of their actual argument types which may be of "any" type. This however excludes alternate return specifiers which therefore must be unconditionally rejected for all standard intrinsics. OK'ed by Steve (see PR), and committed to mainline as obvious after regtesting on x86_64-pc-linux-gnu. Thanks, Harald From 70e24c9682ddbcade0301665bccd8e7f928d0082 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 14 Jan 2022 21:48:15 +0100 Subject: [PATCH] Fortran: always reject alternate return specifier as argument of intrinsics The intrinsics MOVE_ALLOC, C_F_POINTER, and C_F_PROCPOINTER require deferred checks of part of their actual argument types which may be of "any" type. This however excludes alternate return specifiers which therefore must be unconditionally rejected for all standard intrinsics. gcc/fortran/ChangeLog: PR fortran/99256 * intrinsic.c: Do not check formal argument type when checking arguments of intrinsics for alternate return specifiers. gcc/testsuite/ChangeLog: PR fortran/99256 * gfortran.dg/altreturn_11.f90: New test. --- gcc/fortran/intrinsic.c | 2 +- gcc/testsuite/gfortran.dg/altreturn_11.f90 | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/altreturn_11.f90 diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index a7ecdb401ef..9746cd5ddb6 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -4420,7 +4420,7 @@ do_sort: FOR_EACH_VEC_ELT (dummy_args, idx, f) { a = ordered_actual_args[idx]; - if (a && a->label != NULL && f->ts.type) + if (a && a->label != NULL) { gfc_error ("ALTERNATE RETURN not permitted at %L", where); return false; diff --git a/gcc/testsuite/gfortran.dg/altreturn_11.f90 b/gcc/testsuite/gfortran.dg/altreturn_11.f90 new file mode 100644 index 00000000000..be42971d781 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/altreturn_11.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-prune-output "Obsolescent feature: Alternate-return argument" } +! PR fortran/99256 - ICE in variable_check +! Contributed by G.Steimetz + +program test + use iso_c_binding + type(c_ptr) :: i + type(c_funptr) :: p + call move_alloc (*1, *2) ! { dg-error "ALTERNATE RETURN" } + call c_f_pointer (i, *1) ! { dg-error "ALTERNATE RETURN" } + call c_f_procpointer (p, *2) ! { dg-error "ALTERNATE RETURN" } +1 continue +2 stop +end -- 2.31.1