[committed] Fortran: error recovery on checking procedure argument intent [PR103608]
Checks
Commit Message
Dear all,
I've committed the attached obvious and trivial patch for another
NULL pointer dereference on behalf of Steve and after regtesting on
x86_64-pc-linux-gnu as r13-6067-gc75cbeba81e5b4737a9ab7dd28cce650965535a9
Thanks,
Harald
From c75cbeba81e5b4737a9ab7dd28cce650965535a9 Mon Sep 17 00:00:00 2001
From: Steve Kargl <kargl@gcc.gnu.org>
Date: Wed, 15 Feb 2023 22:40:37 +0100
Subject: [PATCH] Fortran: error recovery on checking procedure argument intent
[PR103608]
gcc/fortran/ChangeLog:
PR fortran/103608
* frontend-passes.cc (do_intent): Catch NULL pointer dereference on
reference to invalid formal argument.
gcc/testsuite/ChangeLog:
PR fortran/103608
* gfortran.dg/pr103608.f90: New test.
---
gcc/fortran/frontend-passes.cc | 3 ++-
gcc/testsuite/gfortran.dg/pr103608.f90 | 14 ++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gfortran.dg/pr103608.f90
@@ -3049,7 +3049,8 @@ do_intent (gfc_expr **e)
do_sym = dl->ext.iterator->var->symtree->n.sym;
if (a->expr && a->expr->symtree
- && a->expr->symtree->n.sym == do_sym)
+ && a->expr->symtree->n.sym == do_sym
+ && f->sym)
{
if (f->sym->attr.intent == INTENT_OUT)
gfc_error_now ("Variable %qs at %L set to undefined value "
new file mode 100644
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-options "-w" }
+! PR fortran/103608 - ICE in do_intent
+! Contributed by G.Steinmetz
+
+program p
+ implicit none
+ integer :: i
+ integer :: x ! { dg-error "Alternate return specifier" }
+ x(*) = 0
+ do i = 1, 2
+ print *, x(i) ! { dg-error "Missing alternate return specifier" }
+ end do
+end
--
2.35.3