public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8958] Fortran - correct check for constraint F2008:C628 / F2018:C932
@ 2021-09-03 19:18 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2021-09-03 19:18 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f826c257b6fb64868fd12a52291d1b6f85e1689a
commit r11-8958-gf826c257b6fb64868fd12a52291d1b6f85e1689a
Author: Harald Anlauf <anlauf@gmx.de>
Date: Mon Aug 30 22:41:01 2021 +0200
Fortran - correct check for constraint F2008:C628 / F2018:C932
gcc/fortran/ChangeLog:
PR fortran/101349
* resolve.c (resolve_allocate_expr): An unlimited polymorphic
argument to ALLOCATE must be ALLOCATABLE or a POINTER. Fix the
corresponding check.
gcc/testsuite/ChangeLog:
PR fortran/101349
* gfortran.dg/unlimited_polymorphic_33.f90: New test.
(cherry picked from commit 9213ff13247739d6d335064a6b568278a872a991)
Diff:
---
gcc/fortran/resolve.c | 5 +++--
gcc/testsuite/gfortran.dg/unlimited_polymorphic_33.f90 | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 48e3eb1853c..b6d5f1b7547 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -7830,8 +7830,9 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec)
}
}
- /* Check for F08:C628. */
- if (allocatable == 0 && pointer == 0 && !unlimited)
+ /* Check for F08:C628 (F2018:C932). Each allocate-object shall be a data
+ pointer or an allocatable variable. */
+ if (allocatable == 0 && pointer == 0)
{
gfc_error ("Allocate-object at %L must be ALLOCATABLE or a POINTER",
&e->where);
diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_33.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_33.f90
new file mode 100644
index 00000000000..8bb8864cb26
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_33.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! PR fortran/101349 - ICE in gfc_get_descriptor_field
+! Check constraint F2008:C628 / F2018:C932
+
+subroutine s(x)
+ class(*) :: x(:)
+ allocate (x, source=['abc']) ! { dg-error "must be ALLOCATABLE or a POINTER" }
+end
+
+subroutine t(x)
+ class(*), allocatable :: x(:)
+ allocate (x, source=['abc'])
+end
+
+subroutine u(x)
+ class(*), pointer :: x(:)
+ allocate (x, source=['abc'])
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-03 19:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 19:18 [gcc r11-8958] Fortran - correct check for constraint F2008:C628 / F2018:C932 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).