Re: [PATCH] Fortran: add IEEE_MODES_TYPE, IEEE_GET_MODES and IEEE_SET_MODES
I forgot to include the gfortran.map part of the patch, and so the test failed on platforms that have symbol versioning. Fix below committed to master. FX commit ce8aed75a38b468490ecab4c318e3eb08d468608 (HEAD -> master) Author: Francois-Xavier Coudert Date: 2022-09-21 10:04:22 +0200 Fortran: add symbols in version map for IEEE_GET_MODES and IEEE_SET_MODES The symbols were forgotten in the patch that added IEEE_GET_MODES and IEEE_SET_MODES. 2022-09-21 Francois-Xavier Coudert libgfortran/ * gfortran.map: Add symbols for IEEE_GET_MODES and IEEE_SET_MODES. diff --git a/libgfortran/gfortran.map b/libgfortran/gfortran.map index e0e795c3d48..db9b86cb183 100644 --- a/libgfortran/gfortran.map +++ b/libgfortran/gfortran.map @@ -1759,3 +1759,9 @@ GFORTRAN_12 { _gfortran_transfer_real128_write; #endif } GFORTRAN_10.2; + +GFORTRAN_13 { + global: +__ieee_exceptions_MOD_ieee_get_modes; +__ieee_exceptions_MOD_ieee_set_modes; +} GFORTRAN_12;
Re: [PATCH] Fortran 2018 rounding modes changes
Follow-up patch, including a test, committed as attached. FX 0001-Fortran-handle-RADIX-kind-in-IEEE_SET_ROUNDING_MODE.patch Description: Binary data
Re: [PATCH 09/10] fortran: Support clobbering of variable subreferences [PR88364]
Hi Harald, I think I understand much of what is said, but I feel that I do not really understand what *clobber* means for the different beasts we are discussing (although I have an impression of what it means for a scalar object). Obviously, "clobber" means taking a big stick and hitting the beast in question over the head with it :-) More seriously: My understanding of a clobber it is a hint to the middle end that the value in question will not be used, and that operations leading to this value can be removed, unless they are used otherwise. If I'm wrong or imprecise, I'm sure somebody will correct me :-) Regards Thomas
[PATCH] Fortran: fix ICE in generate_coarray_sym_init [PR82868]
Dear all, I intend to commit the attached, obvious patch for a NULL pointer dereference until tomorrow unless there are comments or objections. We better skip initialization for a symbol which is an associate name. Regtested on x86_64-pc-linux-gnu. Thanks, Harald From 0259762271b2eb430e058b0bff4d7b11513c48c4 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 21 Sep 2022 19:55:30 +0200 Subject: [PATCH] Fortran: fix ICE in generate_coarray_sym_init [PR82868] gcc/fortran/ChangeLog: PR fortran/82868 * trans-decl.cc (generate_coarray_sym_init): Skip symbol if attr.associate_var. gcc/testsuite/ChangeLog: PR fortran/82868 * gfortran.dg/associate_26a.f90: New test. --- gcc/fortran/trans-decl.cc | 1 + gcc/testsuite/gfortran.dg/associate_26a.f90 | 15 +++ 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/associate_26a.f90 diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 908a4c6d42e..5d16d640322 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -5529,6 +5529,7 @@ generate_coarray_sym_init (gfc_symbol *sym) if (sym->attr.dummy || sym->attr.allocatable || !sym->attr.codimension || sym->attr.use_assoc || !sym->attr.referenced + || sym->attr.associate_var || sym->attr.select_type_temporary) return; diff --git a/gcc/testsuite/gfortran.dg/associate_26a.f90 b/gcc/testsuite/gfortran.dg/associate_26a.f90 new file mode 100644 index 000..85aebebd4d8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_26a.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib" } +! +! Test the fix for PR78152 and the followup in PR82868 +! +! Contributed by +! +program co_assoc + implicit none + integer, parameter :: p = 5 + real, allocatable :: a(:,:)[:,:] + allocate (a(p,p)[2,*]) + associate (i => a(1:p, 1:p)) + end associate +end program co_assoc -- 2.35.3
Re: [PATCH 09/10] fortran: Support clobbering of variable subreferences [PR88364]
Le 21/09/2022 à 11:57, Thomas Koenig a écrit : Hi Harald, I think I understand much of what is said, but I feel that I do not really understand what *clobber* means for the different beasts we are discussing (although I have an impression of what it means for a scalar object). Obviously, "clobber" means taking a big stick and hitting the beast in question over the head with it :-) More seriously: My understanding of a clobber it is a hint to the middle end that the value in question will not be used, and that operations leading to this value can be removed, unless they are used otherwise. My understanding is that "clobber" means "overwrite with garbage" for all the beasts we have been discussing, which translates to nothing in the final code, but can be used by the optimizers as Thomas said. This is a bit off-topic but clobbers model registers having their values changed unpredictably or by ways unknown to the compiler, in the backend code, or in inline assembly statements. Here is an excerpt from rtl.texi: @item (clobber @var{x}) Represents the storing or possible storing of an unpredictable, undescribed value into @var{x} I Hope it helps.
Re: [PATCH 09/10] fortran: Support clobbering of variable subreferences [PR88364]
Hi Mikael, Am 21.09.22 um 20:56 schrieb Mikael Morin: Le 21/09/2022 à 11:57, Thomas Koenig a écrit : Hi Harald, I think I understand much of what is said, but I feel that I do not really understand what *clobber* means for the different beasts we are discussing (although I have an impression of what it means for a scalar object). More seriously: My understanding of a clobber it is a hint to the middle end that the value in question will not be used, and that operations leading to this value can be removed, unless they are used otherwise. My understanding is that "clobber" means "overwrite with garbage" for all the beasts we have been discussing, which translates to nothing in the final code, but can be used by the optimizers as Thomas said. This is a bit off-topic but clobbers model registers having their values changed unpredictably or by ways unknown to the compiler, in the backend code, or in inline assembly statements. Here is an excerpt from rtl.texi: @item (clobber @var{x}) Represents the storing or possible storing of an unpredictable, undescribed value into @var{x} ah, I missed that file. I only found references to assembly, and references to registers etc. were not really helpful here. It also says: > If @var{x} is @code{(mem:BLK (const_int 0))} or > @code{(mem:BLK (scratch))}, it means that all memory > locations must be presumed clobbered. ... so this goes into the direction I was thinking of. I Hope it helps.
Proxy ping [PATCH] Fortran: Fix automatic reallocation inside select rank [PR100103]
Dear all, the patch for this PR was submitted for review by Jose here: https://gcc.gnu.org/pipermail/fortran/2021-April/055934.html but unfortunately was never reviewed. I verified that it works on mainline and x86_64-pc-linux-gnu, and I think that it is fine. Although the above mail suggests that there is a dependency on the fix for another PR with a rather lengthy patch, it appears that this is no longer the case. It might be that the fix for PR100245 (another reallocation issue) already did the necessary job. So OK for mainline? Thanks, Harald From 6c93c5058f552f47a3d828d3fb19cca652901299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rui=20Faustino=20de=20Sousa?= Date: Wed, 21 Sep 2022 22:55:02 +0200 Subject: [PATCH] Fortran: Fix automatic reallocation inside select rank [PR100103] gcc/fortran/ChangeLog: PR fortran/100103 * trans-array.cc (gfc_is_reallocatable_lhs): Add select rank temporary associate names as possible targets of automatic reallocation. gcc/testsuite/ChangeLog: PR fortran/100103 * gfortran.dg/PR100103.f90: New test. --- gcc/fortran/trans-array.cc | 4 +- gcc/testsuite/gfortran.dg/PR100103.f90 | 76 ++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/PR100103.f90 diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 05134952db4..795ce14af08 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -10378,7 +10378,7 @@ gfc_is_reallocatable_lhs (gfc_expr *expr) /* An allocatable class variable with no reference. */ if (sym->ts.type == BT_CLASS - && !sym->attr.associate_var + && (!sym->attr.associate_var || sym->attr.select_rank_temporary) && CLASS_DATA (sym)->attr.allocatable && expr->ref && ((expr->ref->type == REF_ARRAY && expr->ref->u.ar.type == AR_FULL @@ -10393,7 +10393,7 @@ gfc_is_reallocatable_lhs (gfc_expr *expr) /* An allocatable variable. */ if (sym->attr.allocatable - && !sym->attr.associate_var + && (!sym->attr.associate_var || sym->attr.select_rank_temporary) && expr->ref && expr->ref->type == REF_ARRAY && expr->ref->u.ar.type == AR_FULL) diff --git a/gcc/testsuite/gfortran.dg/PR100103.f90 b/gcc/testsuite/gfortran.dg/PR100103.f90 new file mode 100644 index 000..21405610a71 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100103.f90 @@ -0,0 +1,76 @@ +! { dg-do run } +! +! Test the fix for PR100103 +! + +program main_p + implicit none + + integer:: i + integer, parameter :: n = 11 + + type :: foo_t +integer :: i + end type foo_t + + type(foo_t), parameter :: a(*) = [(foo_t(i), i=1,n)] + + type(foo_t), allocatable :: bar_d(:) + class(foo_t), allocatable :: bar_p(:) + class(*), allocatable :: bar_u(:) + + + call foo_d(bar_d) + if(.not.allocated(bar_d)) stop 1 + if(any(bar_d%i/=a%i)) stop 2 + deallocate(bar_d) + call foo_p(bar_p) + if(.not.allocated(bar_p)) stop 3 + if(any(bar_p%i/=a%i)) stop 4 + deallocate(bar_p) + call foo_u(bar_u) + if(.not.allocated(bar_u)) stop 5 + select type(bar_u) + type is(foo_t) +if(any(bar_u%i/=a%i)) stop 6 + class default +stop 7 + end select + deallocate(bar_u) + +contains + + subroutine foo_d(that) +type(foo_t), allocatable, intent(out) :: that(..) + +select rank(that) +rank(1) + that = a +rank default + stop 8 +end select + end subroutine foo_d + + subroutine foo_p(that) +class(foo_t), allocatable, intent(out) :: that(..) + +select rank(that) +rank(1) + that = a +rank default + stop 9 +end select + end subroutine foo_p + + subroutine foo_u(that) +class(*), allocatable, intent(out) :: that(..) + +select rank(that) +rank(1) + that = a +rank default + stop 10 +end select + end subroutine foo_u + +end program main_p -- 2.35.3
[OG12][PATCH] OpenMP: Fix ICE with OMP metadirectives
Hello, Here is a patch that fixes an ICE in gfortran triggered by an invalid end statement at the end of an OMP metadirective: ``` !$OMP metadirective ... ... !$OMP end ... ``` Does this fix look correct? Thanks, -- Paul-Antoine ArrasFrom 73ecbc2672a5352a08260f7a9d0de6d2c29ea2b6 Mon Sep 17 00:00:00 2001 From: Paul-Antoine Arras Date: Wed, 21 Sep 2022 15:52:56 + Subject: [PATCH] OpenMP: Fix ICE with OMP metadirectives Problem: ending an OpenMP metadirective block with an OMP end statement results in an internal compiler error. Solution: reject invalid end statements and issue a proper diagnostic. Also add a new test to check this behaviour. gcc/fortran/ChangeLog: * parse.cc (parse_omp_metadirective_body): Reject OMP end statements at the end of an OMP metadirective. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/metadirective-9.f90: New test. --- gcc/fortran/ChangeLog.omp | 5 gcc/fortran/parse.cc | 14 + gcc/testsuite/ChangeLog.omp | 4 +++ .../gfortran.dg/gomp/metadirective-9.f90 | 29 +++ 4 files changed, 52 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90 diff --git gcc/fortran/ChangeLog.omp gcc/fortran/ChangeLog.omp index 8c89cd5bd43..7b253608bf8 100644 --- gcc/fortran/ChangeLog.omp +++ gcc/fortran/ChangeLog.omp @@ -1,3 +1,8 @@ +2022-09-21 Paul-Antoine Arras + +* parse.cc (parse_omp_metadirective_body): Reject OMP end statements +at the end of an OMP metadirective. + 2022-09-09 Tobias Burnus Backport from mainline: diff --git gcc/fortran/parse.cc gcc/fortran/parse.cc index b35d76a4f6b..1f1fa0eba0e 100644 --- gcc/fortran/parse.cc +++ gcc/fortran/parse.cc @@ -5863,6 +5863,20 @@ parse_omp_metadirective_body (gfc_statement omp_st) break; } + if (gfc_state_stack->state == COMP_OMP_METADIRECTIVE + && startswith (gfc_ascii_statement (st), "!$OMP END ")) + { + for (gfc_state_data *p = gfc_state_stack; p; p = p->previous) + if (p->state == COMP_OMP_STRUCTURED_BLOCK) + goto finish; + gfc_error ( + "Unexpected %s statement in an OMP METADIRECTIVE block at %C", + gfc_ascii_statement (st)); + reject_statement (); + st = next_statement (); + } +finish: + gfc_in_metadirective_body = old_in_metadirective_body; if (gfc_state_stack->head) diff --git gcc/testsuite/ChangeLog.omp gcc/testsuite/ChangeLog.omp index e0c8c138620..f075354af4d 100644 --- gcc/testsuite/ChangeLog.omp +++ gcc/testsuite/ChangeLog.omp @@ -1,3 +1,7 @@ +2022-09-21 Paul-Antoine Arras + +* gfortran.dg/gomp/metadirective-9.f90: New test. + 2022-09-09 Paul-Antoine Arras Backport from mainline: diff --git gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90 gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90 new file mode 100644 index 000..4db37dd0ef9 --- /dev/null +++ gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90 @@ -0,0 +1,29 @@ +! { dg-do compile } + +program OpenMP_Metadirective_WrongEnd_Test + + integer :: & +iV, jV, kV + integer, dimension ( 3 ) :: & +lV, uV + logical :: & +UseDevice + +!$OMP metadirective & +!$OMP when ( user = { condition ( UseDevice ) } & +!$OMP : target teams distribute parallel do simd collapse ( 3 ) & +!$OMP private ( iaVS ) ) & +!$OMP default ( parallel do simd collapse ( 3 ) private ( iaVS ) ) +do kV = lV ( 3 ), uV ( 3 ) + do jV = lV ( 2 ), uV ( 2 ) +do iV = lV ( 1 ), uV ( 1 ) + + +end do + end do +end do +!$OMP end target teams distribute parallel do simd ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD statement in an OMP METADIRECTIVE block at .1." } + + +end program + -- 2.31.1
Re: Proxy ping [PATCH] Fortran: Fix automatic reallocation inside select rank [PR100103]
Hello Harald, the patch for this PR was submitted for review by Jose here: https://gcc.gnu.org/pipermail/fortran/2021-April/055934.html but unfortunately was never reviewed. I verified that it works on mainline and x86_64-pc-linux-gnu, and I think that it is fine. Although the above mail suggests that there is a dependency on the fix for another PR with a rather lengthy patch, it appears that this is no longer the case. It might be that the fix for PR100245 (another reallocation issue) already did the necessary job. So OK for mainline? Looks good to me. Thanks for picking up these patches! Best regards Thomas