From patchwork Fri Jun 2 18:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 102660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1208749vqr; Fri, 2 Jun 2023 11:07:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IGSH0UkNh28H8jT70nvpYHcW9nEoSv2hWCBcwl4uQh7owckwT2HncXzPXpz6YV2lDxm1U X-Received: by 2002:a05:6402:1516:b0:514:bcfd:6e2a with SMTP id f22-20020a056402151600b00514bcfd6e2amr3570047edw.2.1685729220007; Fri, 02 Jun 2023 11:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685729219; cv=none; d=google.com; s=arc-20160816; b=NPai2LPhkAAJKEpBGGbWp8FKVl7G/VyXPmtagVV6OXF9YnnAGeP7li8R4ArUrHyPd0 HbBndgpomVEsRwk06ZXzPVfcfm9X9dbsCXkMu2F0KrM213teYFXbYHX0pS3B87DCcNcZ 1huMwMNm9/CAeSxSYlXGluPEbSTzZN6Z2AfZAVfKJFbXgj48PnSpooWKLe5Uw664Qac9 Ko+Au37v5xNK0DIZbbj89a3+HRSnEM3UrIRiJeYEBeUCxvY92zLMZHwaQxI+5mXiUo7U c/BKoNb/NwMBQK4Qn9rjUgNLfq8zF0tzGxyJJA3xhPdoCiAflZWHcJKIxDj/vpZqUsG6 mopw== 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=wOqMS2mr7pKLvPea+c7xS5CLCkaJW0je8xeb+do+Xyk=; b=n/BanKf2LJHhudX2qVT0aYlRxjnxndJAmTa5JbRzl9EAw+bkjXkOFBy2bw4N8vcBq2 V4nF1WLJrd8VJ12JLDAmiwt++y07TfbZa5tEXFzS84DTDW6JEZvRDwjBXoXorgaqpUn2 q7+ppMVwpvf/h1LYaPklGSMsMsObtydBGkYjwsAM4bUGT5nyPZr1R80YAQ0+cQ/0joJC Oq53z1IyuXmwKUsWHKAVZ1VSlmuXeNYjLhLYLAoa6+OkOG8XDx/HqTc4XOBP2yRBEHGm 8+T1mdzip4pX5KbwJtzp5ccMaydCX+Z3l5O3+oKulHK+uLEKU3GCADPOhF0iVbAXwMXa XaOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OUJbqppp; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j13-20020aa7ca4d000000b00514a6bcbfe3si1183513edt.92.2023.06.02.11.06.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 11:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OUJbqppp; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 A868A3857719 for ; Fri, 2 Jun 2023 18:06:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A868A3857719 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685729218; bh=wOqMS2mr7pKLvPea+c7xS5CLCkaJW0je8xeb+do+Xyk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OUJbqppp4s7BAnN5lZ2H7ejM22JvOrtqLD8GHd37wEiLh7bop9NOhkWKRBV1EyJ2m rUQAnvvmJoWYJ7PzyCaxZ385KVKNCCGqYl8HezYlKy4b2ZAaeCTkMc08c7lRDuuG6p O9jYFpqWYQlIxZHAfuCvs1kqFTzYzv1CIbzs+68E= 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.15]) by sourceware.org (Postfix) with ESMTPS id C89F9385772C; Fri, 2 Jun 2023 18:05:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C89F9385772C X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [79.251.15.121] ([79.251.15.121]) by web-mail.gmx.net (3c-app-gmx-bs08.server.lan [172.19.170.59]) (via HTTP); Fri, 2 Jun 2023 20:05:54 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: fix diagnostics for SELECT RANK [PR100607] Date: Fri, 2 Jun 2023 20:05:54 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:l/HNOZ9QWzdR8h/AzOYj9til000i5XbG2I4yg1t+YdCC6S2gqJCDwWIOx04XoP0UcE2Lv C3qGE0qwcdARBcvdlKyItJ5VnglYo2MEhMg+8MsUwzH0U0VfzYr10ObuHjewKb+wz5E9K66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T7GmWOcDzbl2ajCVI7hZ8= X-Spam-Status: No, score=-12.8 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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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?1767615202357075043?= X-GMAIL-MSGID: =?utf-8?q?1767615202357075043?= Dear all, I've committed that attached simple patch on behalf of Steve after discussion in the PR and regtesting on x86_64-pc-linux-gnu. It fixes a duplicate error message and an ICE. Pushed as r14-1505-gfae09dfc0e6bf4cfe35d817558827aea78c6426f . Thanks, Harald From fae09dfc0e6bf4cfe35d817558827aea78c6426f Mon Sep 17 00:00:00 2001 From: Steve Kargl Date: Fri, 2 Jun 2023 19:44:11 +0200 Subject: [PATCH] Fortran: fix diagnostics for SELECT RANK [PR100607] gcc/fortran/ChangeLog: PR fortran/100607 * resolve.cc (resolve_select_rank): Remove duplicate error. (resolve_fl_var_and_proc): Prevent NULL pointer dereference and suppress error message for temporary. gcc/testsuite/ChangeLog: PR fortran/100607 * gfortran.dg/select_rank_6.f90: New test. --- gcc/fortran/resolve.cc | 10 ++--- gcc/testsuite/gfortran.dg/select_rank_6.f90 | 48 +++++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/select_rank_6.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 2ba3101f1fe..fd059dddf05 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -10020,11 +10020,6 @@ resolve_select_rank (gfc_code *code, gfc_namespace *old_ns) || gfc_expr_attr (code->expr1).pointer)) gfc_error ("RANK (*) at %L cannot be used with the pointer or " "allocatable selector at %L", &c->where, &code->expr1->where); - - if (case_value == -1 && (gfc_expr_attr (code->expr1).allocatable - || gfc_expr_attr (code->expr1).pointer)) - gfc_error ("RANK (*) at %L cannot be used with the pointer or " - "allocatable selector at %L", &c->where, &code->expr1->where); } /* Add EXEC_SELECT to switch on rank. */ @@ -13262,7 +13257,10 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag) if (allocatable) { - if (dimension && as->type != AS_ASSUMED_RANK) + if (dimension + && as + && as->type != AS_ASSUMED_RANK + && !sym->attr.select_rank_temporary) { gfc_error ("Allocatable array %qs at %L must have a deferred " "shape or assumed rank", sym->name, &sym->declared_at); diff --git a/gcc/testsuite/gfortran.dg/select_rank_6.f90 b/gcc/testsuite/gfortran.dg/select_rank_6.f90 new file mode 100644 index 00000000000..d0121777bb5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_rank_6.f90 @@ -0,0 +1,48 @@ +! { dg-do compile } +! PR fortran/100607 - fix diagnostics for SELECT RANK +! Contributed by T.Burnus + +program p + implicit none + integer, allocatable :: A(:,:,:) + + allocate(a(5:6,-2:2, 99:100)) + call foo(a) + call bar(a) + +contains + + subroutine foo(x) + integer, allocatable :: x(..) + if (rank(x) /= 3) stop 1 + if (any (lbound(x) /= [5, -2, 99])) stop 2 + + select rank (x) + rank(3) + if (any (lbound(x) /= [5, -2, 99])) stop 3 + end select + + select rank (x) ! { dg-error "pointer or allocatable selector at .2." } + rank(*) ! { dg-error "pointer or allocatable selector at .2." } + if (rank(x) /= 1) stop 4 + if (lbound(x, 1) /= 1) stop 5 + end select + end + + subroutine bar(x) + integer :: x(..) + if (rank(x) /= 3) stop 6 + if (any (lbound(x) /= 1)) stop 7 + + select rank (x) + rank(3) + if (any (lbound(x) /= 1)) stop 8 + end select + + select rank (x) + rank(*) + if (rank(x) /= 1) stop 9 + if (lbound(x, 1) /= 1) stop 10 + end select + end +end -- 2.35.3