public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, committed] Fortran: error recovery on checking procedure argument intent [PR103608]
@ 2023-02-15 21:50 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-02-15 21:50 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 236 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr103608.diff --]
[-- Type: text/x-patch, Size: 1880 bytes --]

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

diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
index 1cbc63016da..02fcb41dbc4 100644
--- a/gcc/fortran/frontend-passes.cc
+++ b/gcc/fortran/frontend-passes.cc
@@ -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 "
diff --git a/gcc/testsuite/gfortran.dg/pr103608.f90 b/gcc/testsuite/gfortran.dg/pr103608.f90
new file mode 100644
index 00000000000..5c37cb78dc6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr103608.f90
@@ -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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-15 21:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 21:50 [PATCH, committed] Fortran: error recovery on checking procedure argument intent [PR103608] Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).