public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3865] Fortran: avoid NULL pointer dereference on bad EQUIVALENCEs [PR107559]
@ 2022-11-09 20:11 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-11-09 20:11 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e505f7493bed1395d121d2f53137ec11706fa42e

commit r13-3865-ge505f7493bed1395d121d2f53137ec11706fa42e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Nov 9 21:05:28 2022 +0100

    Fortran: avoid NULL pointer dereference on bad EQUIVALENCEs [PR107559]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/107559
            * resolve.cc (resolve_equivalence): Avoid NULL pointer dereference
            while emitting diagnostics for bad EQUIVALENCEs.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/107559
            * gfortran.dg/pr107559.f90: New test.

Diff:
---
 gcc/fortran/resolve.cc                 |  2 ++
 gcc/testsuite/gfortran.dg/pr107559.f90 | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 9202e2f10ad..5ff1cd070ac 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -17218,6 +17218,7 @@ resolve_equivalence (gfc_equiv *eq)
 	    "statement at %L with different type objects";
       if ((object ==2
 	   && last_eq_type == SEQ_MIXED
+	   && last_where
 	   && !gfc_notify_std (GFC_STD_GNU, msg, first_sym->name, last_where))
 	  || (eq_type == SEQ_MIXED
 	      && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where)))
@@ -17227,6 +17228,7 @@ resolve_equivalence (gfc_equiv *eq)
 	    "statement at %L with objects of different type";
       if ((object ==2
 	   && last_eq_type == SEQ_NONDEFAULT
+	   && last_where
 	   && !gfc_notify_std (GFC_STD_GNU, msg, first_sym->name, last_where))
 	  || (eq_type == SEQ_NONDEFAULT
 	      && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where)))
diff --git a/gcc/testsuite/gfortran.dg/pr107559.f90 b/gcc/testsuite/gfortran.dg/pr107559.f90
new file mode 100644
index 00000000000..714e236df50
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr107559.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+! PR fortran/107559 - ICE in resolve_equivalence
+! Contributed by G.Steinmetz
+
+module m
+  implicit none
+  integer, protected :: a ! { dg-error "Fortran 2003: PROTECTED attribute" }
+  integer :: b
+  equivalence (a, b)      ! { dg-error "has no IMPLICIT type" }
+end

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

only message in thread, other threads:[~2022-11-09 20:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 20:11 [gcc r13-3865] Fortran: avoid NULL pointer dereference on bad EQUIVALENCEs [PR107559] 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).