* [PATCH] PR fortran/100602 - [11/12 Regression] Erroneous "pointer argument is not associated" runtime error
@ 2021-05-18 18:36 Harald Anlauf
2021-05-25 19:41 ` PING " Harald Anlauf
2021-05-27 3:24 ` Jerry DeLisle
0 siblings, 2 replies; 3+ messages in thread
From: Harald Anlauf @ 2021-05-18 18:36 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 727 bytes --]
The generation of the new runtime check picked up the wrong attributes
in the case of CLASS array arguments. There is related new code in
gfc_conv_procedure_call which served as reference for the fix.
Regtested on x86_64-pc-linux-gnu.
OK for mainline / 11-branch?
Thanks,
Harald
Fortran: Fix erroneous "pointer argument is not associated" runtime error
For CLASS arrays we need to use the CLASS data attributes to determine
which runtime check to generate.
gcc/fortran/ChangeLog:
PR fortran/100602
* trans-intrinsic.c (gfc_conv_intrinsic_size): Use CLASS data
attributes for CLASS arrays for generation of runtime error.
gcc/testsuite/ChangeLog:
PR fortran/100602
* gfortran.dg/pointer_check_14.f90: New test.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr100602.patch --]
[-- Type: text/x-patch, Size: 1789 bytes --]
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 4d7451479d3..7ad297905b5 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -7999,7 +7999,14 @@ gfc_conv_intrinsic_size (gfc_se * se, gfc_expr * expr)
tree temp;
tree cond;
- attr = sym ? sym->attr : gfc_expr_attr (e);
+ if (e->symtree->n.sym && IS_CLASS_ARRAY (e->symtree->n.sym))
+ {
+ attr = CLASS_DATA (e->symtree->n.sym)->attr;
+ attr.pointer = attr.class_pointer;
+ }
+ else
+ attr = gfc_expr_attr (e);
+
if (attr.allocatable)
msg = xasprintf ("Allocatable argument '%s' is not allocated",
e->symtree->n.sym->name);
diff --git a/gcc/testsuite/gfortran.dg/pointer_check_14.f90 b/gcc/testsuite/gfortran.dg/pointer_check_14.f90
new file mode 100644
index 00000000000..8ef6b3611fa
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pointer_check_14.f90
@@ -0,0 +1,28 @@
+! { dg-do run }
+! { dg-options "-fcheck=pointer -fdump-tree-original" }
+! PR100602 - Erroneous "pointer argument is not associated" runtime error
+
+module m
+ type :: T
+ end type
+contains
+ subroutine f(this)
+ class(T), intent(in) :: this(:)
+ class(T), allocatable :: ca(:)
+ class(T), pointer :: cp(:)
+ if (size (this) == 0) return
+ write(*,*) size (this)
+ stop 1
+ write(*,*) size (ca) ! Check #1
+ write(*,*) size (cp) ! Check #2
+ end subroutine f
+end module
+
+program main
+ use m
+ call f([T::])
+end program
+
+! { dg-final { scan-tree-dump-times "_gfortran_runtime_error_at" 2 "original" } }
+! { dg-final { scan-tree-dump-times "Allocatable argument .*ca" 1 "original" } }
+! { dg-final { scan-tree-dump-times "Pointer argument .*cp" 1 "original" } }
^ permalink raw reply [flat|nested] 3+ messages in thread
* PING [PATCH] PR fortran/100602 - [11/12 Regression] Erroneous "pointer argument is not associated" runtime error
2021-05-18 18:36 [PATCH] PR fortran/100602 - [11/12 Regression] Erroneous "pointer argument is not associated" runtime error Harald Anlauf
@ 2021-05-25 19:41 ` Harald Anlauf
2021-05-27 3:24 ` Jerry DeLisle
1 sibling, 0 replies; 3+ messages in thread
From: Harald Anlauf @ 2021-05-25 19:41 UTC (permalink / raw)
To: Harald Anlauf; +Cc: fortran, gcc-patches
*PING*
> Gesendet: Dienstag, 18. Mai 2021 um 20:36 Uhr
> Von: "Harald Anlauf" <anlauf@gmx.de>
> An: "fortran" <fortran@gcc.gnu.org>, "gcc-patches" <gcc-patches@gcc.gnu.org>
> Betreff: [PATCH] PR fortran/100602 - [11/12 Regression] Erroneous "pointer argument is not associated" runtime error
>
> The generation of the new runtime check picked up the wrong attributes
> in the case of CLASS array arguments. There is related new code in
> gfc_conv_procedure_call which served as reference for the fix.
>
> Regtested on x86_64-pc-linux-gnu.
>
> OK for mainline / 11-branch?
>
> Thanks,
> Harald
>
>
> Fortran: Fix erroneous "pointer argument is not associated" runtime error
>
> For CLASS arrays we need to use the CLASS data attributes to determine
> which runtime check to generate.
>
> gcc/fortran/ChangeLog:
>
> PR fortran/100602
> * trans-intrinsic.c (gfc_conv_intrinsic_size): Use CLASS data
> attributes for CLASS arrays for generation of runtime error.
>
> gcc/testsuite/ChangeLog:
>
> PR fortran/100602
> * gfortran.dg/pointer_check_14.f90: New test.
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PR fortran/100602 - [11/12 Regression] Erroneous "pointer argument is not associated" runtime error
2021-05-18 18:36 [PATCH] PR fortran/100602 - [11/12 Regression] Erroneous "pointer argument is not associated" runtime error Harald Anlauf
2021-05-25 19:41 ` PING " Harald Anlauf
@ 2021-05-27 3:24 ` Jerry DeLisle
1 sibling, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2021-05-27 3:24 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
On 5/18/21 11:36 AM, Harald Anlauf via Fortran wrote:
> The generation of the new runtime check picked up the wrong attributes
> in the case of CLASS array arguments. There is related new code in
> gfc_conv_procedure_call which served as reference for the fix.
>
> Regtested on x86_64-pc-linux-gnu.
>
> OK for mainline / 11-branch?
>
> Thanks,
> Harald
>
>
> Fortran: Fix erroneous "pointer argument is not associated" runtime error
>
> For CLASS arrays we need to use the CLASS data attributes to determine
> which runtime check to generate.
>
> gcc/fortran/ChangeLog:
>
> PR fortran/100602
> * trans-intrinsic.c (gfc_conv_intrinsic_size): Use CLASS data
> attributes for CLASS arrays for generation of runtime error.
>
> gcc/testsuite/ChangeLog:
>
> PR fortran/100602
> * gfortran.dg/pointer_check_14.f90: New test.
>
Yes, OK for both, thanks
Jerry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-27 3:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 18:36 [PATCH] PR fortran/100602 - [11/12 Regression] Erroneous "pointer argument is not associated" runtime error Harald Anlauf
2021-05-25 19:41 ` PING " Harald Anlauf
2021-05-27 3:24 ` Jerry DeLisle
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).