[Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646

2023-03-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104572

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Target Milestone|--- |13.0
 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #3)
> I'm fine with gfortran emitting either error message.
> As we've both put eyes on the bug, go ahead and use
> your error message and commit.

When using -std=f2018, the new testcase emits:

gcc/testsuite/gfortran.dg/pr104572.f90:12:17:

   12 |   subroutine s(*) ! { dg-error "Argument of FINAL procedure" }
  | 1
Warning: Obsolescent feature: Alternate-return argument at (1)
gcc/testsuite/gfortran.dg/pr104572.f90:12:14:

   12 |   subroutine s(*) ! { dg-error "Argument of FINAL procedure" }
  |  1
Error: Argument of FINAL procedure at (1) must be of type 't'

The error message is also close to that emitted by other brands.

***

Closing.

[Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646

2023-03-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104572

--- Comment #4 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:3e791f45ded89626bc1f9f8013728f6e035801b2

commit r13-6812-g3e791f45ded89626bc1f9f8013728f6e035801b2
Author: Harald Anlauf 
Date:   Wed Mar 22 19:20:41 2023 +0100

Fortran: improve checking of FINAL subroutine arguments [PR104572]

gcc/fortran/ChangeLog:

PR fortran/104572
* resolve.cc (gfc_resolve_finalizers): Argument of a FINAL
subroutine
cannot be an alternate return.

gcc/testsuite/ChangeLog:

PR fortran/104572
* gfortran.dg/pr104572.f90: New test.

Co-authored-by: Steven G. Kargl 

[Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646

2023-03-21 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104572

--- Comment #3 from Steve Kargl  ---
On Tue, Mar 21, 2023 at 09:02:14PM +, anlauf at gcc dot gnu.org wrote:
> --- Comment #2 from anlauf at gcc dot gnu.org ---
> (In reply to kargl from comment #1)
> > Self explanatory.
> > 
> > diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
> 
> Yes.  Either this or:

I'm fine with gfortran emitting either error message.
As we've both put eyes on the bug, go ahead and use
your error message and commit.

[Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646

2023-03-21 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104572

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> Self explanatory.
> 
> diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc

Yes.  Either this or:

@@ -13986,6 +13995,13 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool
*finalizable)
}
   arg = dummy_args->sym;

+  if (!arg)
+   {
+ gfc_error ("Argument of FINAL procedure at %L must be of type %qs",
+>proc_sym->declared_at, derived->name);
+ goto error;
+   }
+
   if (arg->as && arg->as->type == AS_ASSUMED_RANK
  && ((list != derived->f2k_derived->finalizers) || list->next))
{

[Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646

2022-02-16 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104572

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P4
 Ever confirmed|0   |1
   Last reconfirmed||2022-02-16
 CC||kargl at gcc dot gnu.org
 Status|UNCONFIRMED |NEW

--- Comment #1 from kargl at gcc dot gnu.org ---
Self explanatory.

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 835a4783718..1e7c3a07d0e 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -13643,6 +13653,13 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool
*finalizable)
}
   arg = dummy_args->sym;

+  if (!arg)
+   {
+ gfc_error ("Argument of FINAL procedure at %L cannot be an "
+"alternate return", >proc_sym->declared_at);
+ goto error;
+   }
+
   /* This argument must be of our type.  */
   if (arg->ts.type != BT_DERIVED || arg->ts.u.derived != derived)
{