From c212316b4a774f8283f097d46e56fb8256502304 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 8 Dec 2019 13:42:42 +0000 Subject: [PATCH] Error on Associate with a program. 2018-12-08 Thomas Koenig PR fortran/92780 * resolve.c (resolve_assoc_var): Issue error if the associating entity is a program. 2018-12-08 Thomas Koenig PR fortran/92780 * gfortran.dg/associate_50.f90: New test. From-SVN: r279088 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/associate_50.f90 | 8 ++++++++ 4 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/associate_50.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5265c2c3794..c3a4c3adcdb 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-12-08 Thomas Koenig + + PR fortran/92780 + * resolve.c (resolve_assoc_var): Issue error if the associating + entity is a program. + 2018-12-08 Thomas Koenig PR fortran/92764 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 278dad363fd..b437c595500 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -8842,6 +8842,12 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target) gcc_assert (target->symtree); tsym = target->symtree->n.sym; + if (tsym->attr.flavor == FL_PROGRAM) + { + gfc_error ("Associating entity %qs at %L is a PROGRAM", + tsym->name, &target->where); + return; + } sym->attr.asynchronous = tsym->attr.asynchronous; sym->attr.volatile_ = tsym->attr.volatile_; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2f9b47a3b6..8e8e1e9b532 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-08 Thomas Koenig + + PR fortran/92780 + * gfortran.dg/associate_50.f90: New test. + 2018-12-08 Thomas Koenig PR fortran/92764 diff --git a/gcc/testsuite/gfortran.dg/associate_50.f90 b/gcc/testsuite/gfortran.dg/associate_50.f90 new file mode 100644 index 00000000000..d759db59b29 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_50.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR 92780 - this used to ICE instead of being rejected. +! Test case by Gerhard Steinmetz. + +program p + associate (y => p) ! { dg-error "is a PROGRAM" } + end associate +end program p -- 2.30.2