From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id EF1923846454; Sat, 10 Apr 2021 21:18:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EF1923846454 Received: by mail-wr1-x431.google.com with SMTP id x7so8997464wrw.10; Sat, 10 Apr 2021 14:18:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=eBoktYzimfEJd8pAp4hqMk5KucFFwbLg3UhFRY389AA=; b=OljtI83mfvuYZ7WsPs1y34M2Xs99xb18fZS1QdJFuiVLlACzWzC6UspSNY+YxelHpV bXykn3LQA7sF9F7KunnJK6vqI0LwV9EWDE2g+ZZqWgUh1grcIaomPjIkRjEZnxLopJuD pImnZ4xQuWBzQQmn4l8oFj6/69aJ35G6LML11tPdoQ6C1fJqzCclBafyn1AznlxC+nV7 uRS/qLKIkvbnjmjd5fILAw1ihntf6FWeT4Ua9VBAxBjCLUnXcRN91QWPZk8vuEUZ3xBA Lv4DccR6IRIINWrjGDcSpFooUVUnX9Vs7qtCi4UzoC/74ecno04pzEwp34gZfGosVjuq C/ow== X-Gm-Message-State: AOAM532CWRXQe/LaOd8T4wB7FU6BxAZbHpX1myOSXDze0MPoGu3nkhdH GjiG5D/EgCp+YZyzfQ8jTzowgf32jQs= X-Google-Smtp-Source: ABdhPJzJ2rg5xTEtX32zZFSGcSfbHlnQX8/KWpDCe/aJKQqDaq/SbrCHf/rCgdRXUhPcMeDxpulHRQ== X-Received: by 2002:a5d:438f:: with SMTP id i15mr23731675wrq.351.1618089494948; Sat, 10 Apr 2021 14:18:14 -0700 (PDT) Received: from ?IPv6:2001:8a0:7d5c:3000:9cb3:394b:9323:981? ([2001:8a0:7d5c:3000:9cb3:394b:9323:981]) by smtp.googlemail.com with ESMTPSA id 66sm2402187wmb.36.2021.04.10.14.18.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 10 Apr 2021 14:18:14 -0700 (PDT) To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org From: =?UTF-8?Q?Jos=c3=a9_Rui_Faustino_de_Sousa?= Subject: [Patch, fortran] PR fortran/100024 PR fortran/100025 ICE on subroutine missing explicit interface Message-ID: Date: Sat, 10 Apr 2021 21:18:13 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4FD847503BD1CD08E611268B" Content-Language: en-US X-Spam-Status: No, score=-11.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_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 21:18:17 -0000 This is a multi-part message in MIME format. --------------4FD847503BD1CD08E611268B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi all! Proposed patch to PR100024 & PR100025 - ICE on missing polymorphic argument. Patch tested only on x86_64-pc-linux-gnu. Remove assertion checking for possible assumed rank arrays and added an explicit error message. Change if clause to allow the handling of assumed-rank arrays as arrays. Thank you very much. Best regards, José Rui Fortran: Fix ICE on the handling of assumed-rank procedures [PR100024/PR100025] gcc/fortran/ChangeLog: * interface.c (argument_rank_mismatch): Remove assertion and add an explicit error message. (gfc_get_formal_from_actual_arglist): Allow handling of assume-rank arrays. gcc/testsuite/ChangeLog: * gfortran.dg/PR100024.f90: New test. * gfortran.dg/PR100025.f90: New test. --------------4FD847503BD1CD08E611268B Content-Type: text/x-patch; charset=UTF-8; name="PR100025.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="PR100025.patch" diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 60736123550..5868bf23f11 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -2237,8 +2237,11 @@ argument_rank_mismatch (const char *name, locus *where, } else { - gcc_assert (rank2 != -1); - if (rank1 == 0) + if (rank2 == -1) + gfc_error_opt (0, "The assumed-rank array actual argument at %L and " + "actual argument at %L are ambiguous, an explicit " + "interface is required.", where, where_formal); + else if (rank1 == 0) gfc_error_opt (0, "Rank mismatch between actual argument at %L " "and actual argument at %L (scalar and rank-%d)", where, where_formal, rank2); @@ -5358,7 +5361,7 @@ gfc_get_formal_from_actual_arglist (gfc_symbol *sym, s->ts.is_iso_c = 0; s->ts.is_c_interop = 0; s->attr.flavor = FL_VARIABLE; - if (a->expr->rank > 0) + if (a->expr->rank) { s->attr.dimension = 1; s->as = gfc_get_array_spec (); diff --git a/gcc/testsuite/gfortran.dg/PR100024.f90 b/gcc/testsuite/gfortran.dg/PR100024.f90 new file mode 100644 index 00000000000..fe82ef6da0a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100024.f90 @@ -0,0 +1,37 @@ +! { dg-do compile } +! +program foobar + + implicit none + + type :: foo_t + end type foo_t + + class(foo_t), pointer :: a + type(foo_t), target :: b + + call bar1(a) + call bar2(b) + stop + +contains + + subroutine bar1(this) + class(foo_t), pointer, intent(in) :: this(..) + + call foo(this) + return + end subroutine bar1 + + subroutine bar2(this) + type(foo_t), pointer, intent(in) :: this(..) + + call foo(this) + return + end subroutine bar2 + +end program foobar +! { dg-error "Explicit interface required for polymorphic argument at \\\(1\\\)" "" { target "*-*-*" } 22 } +! { dg-excess-errors "" } + + diff --git a/gcc/testsuite/gfortran.dg/PR100025.f90 b/gcc/testsuite/gfortran.dg/PR100025.f90 new file mode 100644 index 00000000000..ef8b58ad94a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100025.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! +program foo_p + + implicit none + + class(*), pointer :: a + + call foo(a) + call sub_s(a) + stop + +contains + + subroutine bar_s(this) + class(*), intent(in) :: this(..) + + call foo(this) + return + end subroutine bar_s + +end program foo_p +! { dg-error "Explicit interface required for polymorphic argument at \\\(1\\\)" "" { target "*-*-*" } 10 } +! { dg-excess-errors "" } + --------------4FD847503BD1CD08E611268B--