From patchwork Mon Mar 20 20:57:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 72447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1433545wrt; Mon, 20 Mar 2023 13:58:31 -0700 (PDT) X-Google-Smtp-Source: AK7set+lyDHHGCMOXMYfGBB/BP3apl25lyH0r4NirFCJ/oI9ISdH45fCOLBa3qKZs7rOPU4Tp8A/ X-Received: by 2002:a17:906:370c:b0:933:3663:a1ea with SMTP id d12-20020a170906370c00b009333663a1eamr438580ejc.57.1679345911257; Mon, 20 Mar 2023 13:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679345911; cv=none; d=google.com; s=arc-20160816; b=clRntokmt1k+SeHVZ8LMjymdpPlC6TWCVvld8vdLPo485hGKO0Y2nqqBjUfuXEa+A6 c+GFTkRIpLf8279zAfOoiULSmR/gjQhGbKBgvdSgCOHh9HbiKLsEiTk5+AJFOgpO3nZ8 U9RcDLVf3zcY9ltxgGHoiKven4e6SzIWzJMi1hPzHLZsvCZELQY9SwdpjfWl04n3aDFt E03FH3wELrhSfKCLslG9lvtqBrTiN9DqInVLw7rjMBfXAAcFSs/XHvewakKA9mk7iVht EZha78dK3Z7b+EKVBeuYvO9d2E01pil4iTMZP91QQmlXItve7+2yicLpUckF669h/bm2 jKmA== 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:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=EXQjWBB3c9coBivKHfUL3bzMqL168aW6MwA3tLeMSTc=; b=LoQk8h8FeT3iSHA/2jwbpF4/bccL+ms6NBsCWFOPobXD7SQSuFwfE7GNte/KTnUBVL AtpQEYBS9whb+VDhcP/74tIgiVMuGoIU9+7cUcJYCsTEhVa9LzzPbbHbSFltA7AyqT7R dStmcm4c/i5Tuhhn98rirEReFwMpgUuVHDn5xUiHq8o7hyUg+NJRlOM0URM4VjjhCMYv 5MpwL+xPbldLGxj86EEuGeOgY0Z5/ySq/9OFInXsi4Vnb/e+jgksELrt5ppWQHTCPJgC MhjwmghgUcXf/H+TKO3bksnv742ALmFRdSXrv1h/PTN1GHr2m6t41+Je65Tu3m6ZfTRG gXJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=jcE5GlMd; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id cb6-20020a170906a44600b0093322cf202csi7770125ejb.28.2023.03.20.13.58.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 13:58:31 -0700 (PDT) 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=jcE5GlMd; 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 427B93858C36 for ; Mon, 20 Mar 2023 20:58:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 427B93858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679345910; bh=EXQjWBB3c9coBivKHfUL3bzMqL168aW6MwA3tLeMSTc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jcE5GlMd19UzYCmXstmeyAAAlCx9tiDyzdrNP+C8/j10vgFIB+Qf3GQygJzSI4vwB oNbJJdKzip1+86IlObKupPpBGvemMBVgwG4eIVEfxF849lXUx83Tn87Xtqk+Hj0xyL CXEfi9KGCNYDv/gQi3jDg8YJADq4kCg//qlzV4qI= 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.21]) by sourceware.org (Postfix) with ESMTPS id 2C7C53858D32; Mon, 20 Mar 2023 20:57:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C7C53858D32 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.84.34] ([93.207.84.34]) by web-mail.gmx.net (3c-app-gmx-bap50.server.lan [172.19.172.120]) (via HTTP); Mon, 20 Mar 2023 21:57:44 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036] Date: Mon, 20 Mar 2023 21:57:44 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:qh/q94+5MW1AbjZMkULnDMqT/0yAs2PQexH3G1Hew668f81LBV2zRBq65E+S4k+9hS4a5 Sz6TBlqX+VfbV1YJTNtdnr757csqhqXlaAesG5tY6qwbjzjuSgrxfDYHR3ocv5y+r9KAwn7whLAs R/Z1TP0sqKXxr8VPQopSM4GEg6B7mR8+x7eCUFia4eDU7oCLTiskGnS6Yra9q3qssXhGf76cDXEY rQgqMqTt6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ID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf 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?1760921818168127569?= X-GMAIL-MSGID: =?utf-8?q?1760921818168127569?= Dear all, the attached trivial patch catches a MODULE PROCEDURE outside of a module interface before we run into an internal error. Regtested on x86_64-pc-linux-gnu. OK for mainline? This PR is marked as an 11/12/13 regression, so this is a candidate for backporting. Thanks, Harald From 9c59709fad91c99041a9cb770b98da17af01d260 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 20 Mar 2023 21:50:59 +0100 Subject: [PATCH] Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036] gcc/fortran/ChangeLog: PR fortran/99036 * decl.cc (gfc_match_modproc): Reject MODULE PROCEDURE if not in a generic module interface. gcc/testsuite/ChangeLog: PR fortran/99036 * gfortran.dg/pr99036.f90: New test. --- gcc/fortran/decl.cc | 1 + gcc/testsuite/gfortran.dg/pr99036.f90 | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr99036.f90 diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index c8f0bb83c2c..b29f491fe1f 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -9998,6 +9998,7 @@ gfc_match_modproc (void) if ((gfc_state_stack->state != COMP_INTERFACE && gfc_state_stack->state != COMP_CONTAINS) || gfc_state_stack->previous == NULL + || !current_interface.type || current_interface.type == INTERFACE_NAMELESS || current_interface.type == INTERFACE_ABSTRACT) { diff --git a/gcc/testsuite/gfortran.dg/pr99036.f90 b/gcc/testsuite/gfortran.dg/pr99036.f90 new file mode 100644 index 00000000000..a6e396f6f71 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr99036.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/99036 - ICE in gfc_current_interface_head +! Contributed by G. Steinmetz + +module m +contains + module procedure s ! { dg-error "must be in a generic module interface" } + end +end -- 2.35.3