From patchwork Sat Jan 28 17:07:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 49873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1426605wrn; Sat, 28 Jan 2023 09:08:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXseJXf45PNzjlkWuEuj8w6hfSGHThNgX8IP3BdSTkDsNo3kvHGif/3GY29HB2oZU3VFisww X-Received: by 2002:a17:906:3a4d:b0:873:393f:1bda with SMTP id a13-20020a1709063a4d00b00873393f1bdamr40029199ejf.47.1674925724695; Sat, 28 Jan 2023 09:08:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674925724; cv=none; d=google.com; s=arc-20160816; b=EB+g8G6L/E8cWODPJCRNjwfCWzBxAQkP7kzsq0QQTjelEz67ITg4ZOa0+goQ8jHUZJ hjW032Mmo6UPaMs7zVupc2Kzg59tYJV4OI4XvQ/WUUsAbbHmuUJFZ0skC67S6Wzc6JNO GQuMtsxEEV9ndl9tUe24jBfUZBGZHRgDNCTF36FgGTssa/uzU5JrHIHe5lHsVd64USHm LA1mXUJBGz3xJSCJWftHCSfFzukxwrk3XDzfVGA109PIRXl2SKerTwQGsMpsHr8ed/9E xsGQm1lXxuJ+1hvxoZTXFoTfK6XVLz1WPFHiD1TG8jRL337Z7m47QUjK4Um9SV1IwU33 /usg== 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=KMk4PzkHGPK3Fvpqy6aa+CiBZXHOYatYWLQV2Ebiq2w=; b=L4PxZHEKcDBQObu9rQsLRuzHNr/mGMKDVycEf21byf63zB4w0aCwL5BmF+BHggM8BE 1rYhE5yASe3eXPU7osDm1VvSHo21bNd968Dk1FpMXDNPQpLoXPGqkxylpEXrTb6z5qLl 1VzV/LlTDKbAJPekC2IK58kj1zSh/0upVeU1CJY20Tj5ND9spLSe6+jYOBBsM6hSucFu Y9dEyNAbwtXeMsKYSmxkPg1vjcptQS7ihsuTyjFeqQQ32e2qSyr+MPfpt3J9kqO2byeK gEBbiGtXGX4U4iO0hjE3v3uzCxlkTvKHmS0yOZ2vk3iXDwlZHen7XHMNPWuqxsUn3Imj WR8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pIepWb63; 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 gg21-20020a170906899500b00885e0bfd7dbsi268488ejc.890.2023.01.28.09.08.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Jan 2023 09:08:44 -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=pIepWb63; 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 AE390385840C for ; Sat, 28 Jan 2023 17:08:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE390385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674925723; bh=KMk4PzkHGPK3Fvpqy6aa+CiBZXHOYatYWLQV2Ebiq2w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pIepWb63eyXtxSOIhUcWe3sn3qf4P2JnwDxBiaIEFPCJozThslsVDBSf+ZWVmZAQ/ Onl011OcWdQTNqRgxOVflAWnfxFTpFgCnyGkZmyCUmfoRZ8ogwGThFPhkoS0k2Hwfg JxsgjSTEOYlUwn0pfiE2EdpKdh+9IqkHKBr72ZCw= 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.15.18]) by sourceware.org (Postfix) with ESMTPS id F2BE03858D20; Sat, 28 Jan 2023 17:07:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2BE03858D20 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.92.92] ([93.207.92.92]) by web-mail.gmx.net (3c-app-gmx-bs11.server.lan [172.19.170.62]) (via HTTP); Sat, 28 Jan 2023 18:07:50 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453] Date: Sat, 28 Jan 2023 18:07:50 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:cLrJU8UyVpT4pGSbI6qT6RVv2jtgXliWmwM59LKaluQPrcG5kxy07wu76wdflAH0xNlDm xELXCyL7Jjn01liuFGQhmi/pZf46aozMXy/QyXyzXmuixHOJb4wwsbkFwmRoZzRXkL7fe7fPlP1i lX1JJy7E8rO2PPkMRkhTPl9J4lXHGUZsfG4NEVswfjmudB9lEG/hbKXHouQ6U5nXYGw9nsfMx076 oKDH9eTr6R+picNV/oHhWO0yworfCtsmhMJ/d7K2rLy+D+FNdru7EBffSKSZiIVs/0WKFPwd0zgI dg= UI-OutboundReport: notjunk:1;M01:P0:zF+ALVZVbXk=;XwicJBrcuYFn3c/s6OMXw1uMbJ0 giY8BB0quHoNR+LGW2N7p3N7sKjNCKXSZoyd3jq88dr5YDBKadRq59mZO0D+XKEzlpbiRW4QF qplZnSD/KkMcL9UuVjNll5II+iWqUBOZSoJISszb1rejGyA5/ynW5DO5GyYLd0Il0N39BhBZU 3E8MkcmtawiH/jWoxTWZ4iKIqygBc5mjyHfTz9tM2M8B8YXliPWuQys2ng6SlcyvvUVCbCTmc /nbOyftbosWIe7V3rcFWvWByiu9ecYYro6iJJvX58Xk/WbJY2iSSszKeA6xkaSxJzrH062a8i CAXKHf/vTPdQFlmBiFHlUm43Jr24NvTq7LMRpO82B3e3/GjV8mM6dN5K7WRGWmjEj6JnJ95gi eB1g8X5+mihUWv+shJ0jjwbHPZ0VTLFfWM6YcD+2Uv89s6S+cGYZYne9AdrQMdy3fDqhVYN83 IMcVjxVrQluupE5Xl6ry34C8uFtwy54dK2BhwjYVBoQ37UTJZ3TUDgopuOpClfKzfOer2+tDM n7OzvaeEgC1jVDwTcpBoA10qGSqYx7jqBmHd96JPNJDO3sNd1Ot55aeRJBsvY7NHm07X1IcPV xSwzmDnZhis32gTGywHtF3i1wHSG1iN4ZqhuAQ5gvYOmeoS/K5KCmJRHJ/LutUBmFHkAcBUae BbhxVsw1cHMXc3KCX/wfvmGkkrxKKEgerzU4cgN4expo5i8bhMdL9LcgTB2YQMVqGYryNa66I lYHBSpVEinGsjpEoe76nkz89SA8+5qqmw/qQqd59rzCxtqJgViUZDX1YyPfLrjgFzXYScV9RV eKsdvZ/UEqsEZaqcprZE/+GtuZzPkK8CNNDgtp6CGt76o= X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_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?1756286917042386372?= X-GMAIL-MSGID: =?utf-8?q?1756286917042386372?= Dear all, a USE associated symbol shall not appear in a COMMON block (F2018:C8121) and needs to be diagnosed. The patch is fairly obvious. Regtested on x86_64-pc-linux-gnu. OK for mainline? As the PR is marked as a 10/11/12/13 regression, I plan to backport as appropriate. Thanks, Harald From 3f0e4b23038ade2cd14d93b0705af93848ee45c2 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 28 Jan 2023 17:59:23 +0100 Subject: [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453] gcc/fortran/ChangeLog: PR fortran/108453 * match.cc (gfc_match_common): A USE associated name shall not appear in a COMMON block (F2018:C8121). gcc/testsuite/ChangeLog: PR fortran/108453 * gfortran.dg/common_27.f90: New test. --- gcc/fortran/match.cc | 10 ++++++++++ gcc/testsuite/gfortran.dg/common_27.f90 | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/common_27.f90 diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 5e933c12931..5eb6d0e1c1d 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -5345,6 +5345,16 @@ gfc_match_common (void) goto cleanup; } + /* F2018:R874: common-block-object is variable-name [ (array-spec) ] + F2018:C8121: A variable-name shall not be a name made accessible + by use association. */ + if (sym->attr.use_assoc) + { + gfc_error ("Symbol %qs at %C is USE associated from module %qs " + "and cannot occur in COMMON", sym->name, sym->module); + goto cleanup; + } + /* Deal with an optional array specification after the symbol name. */ m = gfc_match_array_spec (&as, true, true); diff --git a/gcc/testsuite/gfortran.dg/common_27.f90 b/gcc/testsuite/gfortran.dg/common_27.f90 new file mode 100644 index 00000000000..dcde5de2bd2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_27.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/108453 - a use associated variable cannot occur in COMMON +! Contributed by G.Steinmetz + +module m + type t + end type + real :: r +end +program p + use m, only: t, r + common t ! { dg-error "USE associated from module" } + common /cm/ r ! { dg-error "USE associated from module" } +end -- 2.35.3