public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fortran : ICE in gfc_check_pointer_assign PR95612
@ 2020-07-01  6:12 Mark Eggleston
  2020-07-10  7:24 ` Mark Eggleston
  2020-07-14  3:11 ` Jerry DeLisle
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Eggleston @ 2020-07-01  6:12 UTC (permalink / raw)
  To: gcc-patches, fortran

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

Please find attached a patch which is a fix for PR95612.  The original 
patch is by Steve Kargl.

OK to commit and backport?

Commit message:

Fortran  : ICE in gfc_check_pointer_assign PR95612

Output an error if the right hand value is a zero sized array or
does not have a symbol tree otherwise continue checking.

2020-07-01  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran/

     PR fortran/95612
     * expr.c (gfc_check_pointer_assigb): Output an error if
     rvalue is a zero sized array or output an error if rvalue
     doesn't have a symbol tree.

2020-07-01  Mark Eggleston <markeggleston@gcc.gnu.org>

gcc/testsuite/

     PR fortran/95612
     * gfortran.dg/pr95612.f90: New test.

-- 
https://www.codethink.co.uk/privacy.html


[-- Attachment #2: 0001-Fortran-ICE-in-gfc_check_pointer_assign-PR95612.patch --]
[-- Type: text/x-patch, Size: 2327 bytes --]

From a9b7de8b2002605e1bfc9c11a7fb3708bc1ef371 Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Thu, 11 Jun 2020 11:05:40 +0100
Subject: [PATCH] Fortran  : ICE in gfc_check_pointer_assign PR95612

Output an error if the right hand value is a zero sized array or
does not have a symbol tree otherwise continue checking.

2020-07-01  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran/

	PR fortran/95612
	* expr.c (gfc_check_pointer_assigb): Output an error if
	rvalue is a zero sized array or output an error if rvalue
	doesn't have a symbol tree.

2020-07-01  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

	PR fortran/95612
	* gfortran.dg/pr95612.f90: New test.
---
 gcc/fortran/expr.c                    | 15 ++++++++++++++-
 gcc/testsuite/gfortran.dg/pr95612.f90 |  7 +++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr95612.f90

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 8daa7bb8d06..569f4d9bf06 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4271,7 +4271,20 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
       gfc_symbol *sym;
       bool target;
 
-      gcc_assert (rvalue->symtree);
+      if (gfc_is_size_zero_array (rvalue))
+	{
+	  gfc_error ("Zero-sized array detected at %L where an entity with "
+		     "the TARGET attribute is expected", &rvalue->where);
+	  return false;
+	}
+      else if (!rvalue->symtree)
+	{
+	  gfc_error ("Pointer assignment target in initialization expression "
+		     "does not have the TARGET attribute at %L",
+		     &rvalue->where);
+	  return false;
+	}
+
       sym = rvalue->symtree->n.sym;
 
       if (sym->ts.type == BT_CLASS && sym->attr.class_ok)
diff --git a/gcc/testsuite/gfortran.dg/pr95612.f90 b/gcc/testsuite/gfortran.dg/pr95612.f90
new file mode 100644
index 00000000000..b3cac8c1d81
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95612.f90
@@ -0,0 +1,7 @@
+! { dg-do compile }
+
+program p
+   integer, pointer :: y(:) => shape(1)   ! { dg-error "Zero-sized array detected at .1. where an entity with the TARGET attribute is expected" }
+   integer, pointer :: z(:) => shape([1]) ! { dg-error "Pointer assignment target in initialization expression does not have the TARGET attribute at .1." }
+end
+
-- 
2.11.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fortran : ICE in gfc_check_pointer_assign PR95612
  2020-07-01  6:12 [PATCH] Fortran : ICE in gfc_check_pointer_assign PR95612 Mark Eggleston
@ 2020-07-10  7:24 ` Mark Eggleston
  2020-07-14  3:11 ` Jerry DeLisle
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Eggleston @ 2020-07-10  7:24 UTC (permalink / raw)
  To: gcc-patches, fortran

ping

On 01/07/2020 07:12, Mark Eggleston wrote:
> Please find attached a patch which is a fix for PR95612.  The original 
> patch is by Steve Kargl.
>
> OK to commit and backport?
>
> Commit message:
>
> Fortran  : ICE in gfc_check_pointer_assign PR95612
>
> Output an error if the right hand value is a zero sized array or
> does not have a symbol tree otherwise continue checking.
>
> 2020-07-01  Steven G. Kargl  <kargl@gcc.gnu.org>
>
> gcc/fortran/
>
>     PR fortran/95612
>     * expr.c (gfc_check_pointer_assigb): Output an error if
>     rvalue is a zero sized array or output an error if rvalue
>     doesn't have a symbol tree.
>
> 2020-07-01  Mark Eggleston <markeggleston@gcc.gnu.org>
>
> gcc/testsuite/
>
>     PR fortran/95612
>     * gfortran.dg/pr95612.f90: New test.
>
-- 
https://www.codethink.co.uk/privacy.html


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fortran : ICE in gfc_check_pointer_assign PR95612
  2020-07-01  6:12 [PATCH] Fortran : ICE in gfc_check_pointer_assign PR95612 Mark Eggleston
  2020-07-10  7:24 ` Mark Eggleston
@ 2020-07-14  3:11 ` Jerry DeLisle
  1 sibling, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2020-07-14  3:11 UTC (permalink / raw)
  To: Mark Eggleston, gcc-patches, fortran

OK to commit and backport.

On 6/30/20 11:12 PM, Mark Eggleston wrote:
> Please find attached a patch which is a fix for PR95612.  The original 
> patch is by Steve Kargl.
>
> OK to commit and backport?
>
> Commit message:
>
> Fortran  : ICE in gfc_check_pointer_assign PR95612
>
> Output an error if the right hand value is a zero sized array or
> does not have a symbol tree otherwise continue checking.
>
> 2020-07-01  Steven G. Kargl  <kargl@gcc.gnu.org>
>
> gcc/fortran/
>
>     PR fortran/95612
>     * expr.c (gfc_check_pointer_assigb): Output an error if
>     rvalue is a zero sized array or output an error if rvalue
>     doesn't have a symbol tree.
>
> 2020-07-01  Mark Eggleston <markeggleston@gcc.gnu.org>
>
> gcc/testsuite/
>
>     PR fortran/95612
>     * gfortran.dg/pr95612.f90: New test.
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-14  3:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01  6:12 [PATCH] Fortran : ICE in gfc_check_pointer_assign PR95612 Mark Eggleston
2020-07-10  7:24 ` Mark Eggleston
2020-07-14  3:11 ` 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).