* Fortran: Create CLASS(*) early to avoid ICE [PR99254]
@ 2021-02-25 11:16 Tobias Burnus
2021-03-03 11:47 ` *PING* — " Tobias Burnus
0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2021-02-25 11:16 UTC (permalink / raw)
To: gcc-patches, fortran, Paul Richard Thomas
[-- Attachment #1: Type: text/plain, Size: 1443 bytes --]
The issue is that for CLASS – and in particular CLASS(*)
the ts.u.derived->components is not yet created when it is
accessed. – PR99138 shows a similar case (unfixed!
See comment 5 and initial report for two examples).
There is an issue for code like:
class(*) var
dimension :: var(..)
that the attribute is not properly encoded in the class.
That's independent of this patch, cf. PR fortran/99266.
NOTE: This patch causes a regression:
subroutine foo()
class(*) :: x
allocatable :: x
is now rejected with:
CLASS variable ‘x’ at (1) must be dummy, allocatable or pointer
HOWEVER: While that was accepted before,
subroutine foo(dummy)
class(*) :: dummy
allocatable :: dummy
failed before and still fails. (→ class_ok handling in
gfc_build_class_symbol).
All those issues are tracked in that PR fortran/99266.
OK for the trunk? What about GCC 10??
I am unsure about GCC 10 due to the new regression;
the issue (PR99254) was reported as new ICE between
20190825 and 20190901.
Tobias
PS: I still do not like the way we represent CLASS internally,
but I think I had complained about this already years ago...
Can proponents of the current way please look at
PR fortran/99266 ?
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
[-- Attachment #2: class-star.diff --]
[-- Type: text/x-patch, Size: 2438 bytes --]
Fortran: Create CLASS(*) early to avoid ICE [PR99254]
gcc/fortran/ChangeLog:
PR fortran/99254
* class.c (gfc_build_class_symbol): Always build for CLASS(*).
gcc/testsuite/ChangeLog:
PR fortran/99254
* gfortran.dg/class_72.f90: New test.
* gfortran.dg/pr96086.f90: Update dg-error.
gcc/fortran/class.c | 5 ++++-
gcc/testsuite/gfortran.dg/class_72.f90 | 26 ++++++++++++++++++++++++++
gcc/testsuite/gfortran.dg/pr96086.f90 | 4 ++--
3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 89353218417..e49f5a5df77 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -659,7 +659,10 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr,
attr->class_ok = attr->dummy || attr->pointer || attr->allocatable
|| attr->select_type_temporary || attr->associate_var;
- if (!attr->class_ok)
+ bool build_star = (ts->u.derived && !ts->u.derived->components
+ && ts->u.derived->attr.unlimited_polymorphic);
+
+ if (!attr->class_ok && !build_star)
/* We cannot build the class container yet. */
return true;
diff --git a/gcc/testsuite/gfortran.dg/class_72.f90 b/gcc/testsuite/gfortran.dg/class_72.f90
new file mode 100644
index 00000000000..0e181b27086
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/class_72.f90
@@ -0,0 +1,26 @@
+! { dg-do compile }
+!
+! PR fortran/99254
+!
+! Contributed by G. Steinmetz
+!
+subroutine s1
+ class(*) :: x(..) ! { dg-error "must be dummy, allocatable or pointer" }
+ select rank (y => x)
+ rank (1)
+ end select
+end
+
+subroutine s2
+ class(*), allocatable :: x(..) ! { dg-error "Assumed-rank array at .1. must be a dummy argument" }
+ select rank (y => x)
+ rank (1)
+ end select
+end
+
+subroutine s3(x)
+ class(*) :: x(..)
+ select rank (y => x)
+ rank (1)
+ end select
+end
diff --git a/gcc/testsuite/gfortran.dg/pr96086.f90 b/gcc/testsuite/gfortran.dg/pr96086.f90
index b80967a7a07..58f11f51028 100644
--- a/gcc/testsuite/gfortran.dg/pr96086.f90
+++ b/gcc/testsuite/gfortran.dg/pr96086.f90
@@ -2,7 +2,7 @@
! PR fortran/96086 - ICE in gfc_match_select_rank, at fortran/match.c:6645
subroutine s
- class(*) :: x(..) ! { dg-error "Assumed-rank array" }
- select rank (y => x) ! { dg-error "CLASS variable" }
+ class(*) :: x(..) ! { dg-error "must be dummy, allocatable or pointer" }
+ select rank (y => x)
end select
end
^ permalink raw reply [flat|nested] 3+ messages in thread
* *PING* — Re: Fortran: Create CLASS(*) early to avoid ICE [PR99254]
2021-02-25 11:16 Fortran: Create CLASS(*) early to avoid ICE [PR99254] Tobias Burnus
@ 2021-03-03 11:47 ` Tobias Burnus
0 siblings, 0 replies; 3+ messages in thread
From: Tobias Burnus @ 2021-03-03 11:47 UTC (permalink / raw)
To: gcc-patches, fortran, Paul Richard Thomas
*PING*
I think the patch is an improvement, even though there is a small
regression and many issues are not covered: PR fortran/99266 and as
explained below.
On 25.02.21 12:16, Tobias Burnus wrote:
> The issue is that for CLASS – and in particular CLASS(*)
> the ts.u.derived->components is not yet created when it is
> accessed. – PR99138 shows a similar case (unfixed!
> See comment 5 and initial report for two examples).
>
> There is an issue for code like:
> class(*) var
> dimension :: var(..)
> that the attribute is not properly encoded in the class.
> That's independent of this patch, cf. PR fortran/99266.
>
> NOTE: This patch causes a regression:
> subroutine foo()
> class(*) :: x
> allocatable :: x
> is now rejected with:
> CLASS variable ‘x’ at (1) must be dummy, allocatable or pointer
>
> HOWEVER: While that was accepted before,
> subroutine foo(dummy)
> class(*) :: dummy
> allocatable :: dummy
> failed before and still fails. (→ class_ok handling in
> gfc_build_class_symbol).
>
> All those issues are tracked in that PR fortran/99266.
>
> OK for the trunk? What about GCC 10??
>
> I am unsure about GCC 10 due to the new regression;
> the issue (PR99254) was reported as new ICE between
> 20190825 and 20190901.
>
> Tobias
>
> PS: I still do not like the way we represent CLASS internally,
> but I think I had complained about this already years ago...
> Can proponents of the current way please look at
> PR fortran/99266 ?
>
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
^ permalink raw reply [flat|nested] 3+ messages in thread
* *PING* — Re: Fortran: Create CLASS(*) early to avoid ICE [PR99254]
@ 2021-03-07 17:34 dhumieres.dominique
0 siblings, 0 replies; 3+ messages in thread
From: dhumieres.dominique @ 2021-03-07 17:34 UTC (permalink / raw)
To: tobias; +Cc: fortran
Hi Tobias,
I just tested your patch and I see a regression:
FAIL: gfortran.dg/unlimited_polymorphic_28.f90 -O (test for errors,
line 24)
Cheers,
Dominique
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-07 17:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25 11:16 Fortran: Create CLASS(*) early to avoid ICE [PR99254] Tobias Burnus
2021-03-03 11:47 ` *PING* — " Tobias Burnus
2021-03-07 17:34 dhumieres.dominique
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).