* [Fortran, Patch, pr67538, v1] ICE with invalid source allocation
@ 2016-04-03 16:13 Andre Vehreschild
2016-04-03 19:23 ` Jerry DeLisle
0 siblings, 1 reply; 3+ messages in thread
From: Andre Vehreschild @ 2016-04-03 16:13 UTC (permalink / raw)
To: GCC-Patches-ML, GCC-Fortran-ML
[-- Attachment #1: Type: text/plain, Size: 434 bytes --]
Hi all,
the attached patch checks that for F2008-style allocate(arr1, source=s)
the expression in s is array valued, when arr1 has no array spec and
emits an error message saying:
Array specification or array-valued SOURCE= expression required in ALLOCATE statement at (1)
This fixes the ICE.
Bootstrapped and regtests ok on x86_64-linux-gnu/F23. Ok for trunk?
Regards,
Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: pr67538_1.clog --]
[-- Type: application/octet-stream, Size: 422 bytes --]
gcc/fortran/ChangeLog:
2016-04-03 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/67538
* resolve.c (resolve_allocate_expr): Emit error message when no
array spec and no array valued source= expression is given in an
F2008 allocate() for an array to allocate.
gcc/testsuite/ChangeLog:
2016-04-03 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/67538
* gfortran.dg/allocate_with_source_19.f08: New test.
[-- Attachment #3: pr67538_1.patch --]
[-- Type: text/x-patch, Size: 1456 bytes --]
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 55ab2ec..f5cd588 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -7217,7 +7217,15 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec)
if (!gfc_notify_std (GFC_STD_F2008, "Array specification required "
"in ALLOCATE statement at %L", &e->where))
goto failure;
- *array_alloc_wo_spec = true;
+ if (code->expr3->rank != 0)
+ *array_alloc_wo_spec = true;
+ else
+ {
+ gfc_error ("Array specification or array-valued SOURCE= "
+ "expression required in ALLOCATE statement at %L",
+ &e->where);
+ goto failure;
+ }
}
else
{
diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_19.f08 b/gcc/testsuite/gfortran.dg/allocate_with_source_19.f08
new file mode 100644
index 0000000..ff84510
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/allocate_with_source_19.f08
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options -std=f2008 }
+
+! Contributed by mrestelli@gmail.com
+! Check that instead of an ICE the error message is emitted.
+
+module m
+ implicit none
+contains
+
+ subroutine s()
+ real, allocatable :: x(:)
+ real :: y
+
+ y = 5.0
+ ! x either needs an array spec, or y needs to be an array.
+ allocate( x , source=y ) ! { dg-error "Array specification or array-valued SOURCE= expression required in ALLOCATE statement" }
+
+ end subroutine s
+
+end module m
+
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Fortran, Patch, pr67538, v1] ICE with invalid source allocation
2016-04-03 16:13 [Fortran, Patch, pr67538, v1] ICE with invalid source allocation Andre Vehreschild
@ 2016-04-03 19:23 ` Jerry DeLisle
2016-04-04 10:33 ` Andre Vehreschild
0 siblings, 1 reply; 3+ messages in thread
From: Jerry DeLisle @ 2016-04-03 19:23 UTC (permalink / raw)
To: Andre Vehreschild, GCC-Patches-ML, GCC-Fortran-ML
On 04/03/2016 09:13 AM, Andre Vehreschild wrote:
> Hi all,
>
> the attached patch checks that for F2008-style allocate(arr1, source=s)
> the expression in s is array valued, when arr1 has no array spec and
> emits an error message saying:
>
> Array specification or array-valued SOURCE= expression required in ALLOCATE statement at (1)
>
> This fixes the ICE.
>
> Bootstrapped and regtests ok on x86_64-linux-gnu/F23. Ok for trunk?
>
> Regards,
> Andre
>
Yes, OK, thanks for patches.
Jerry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Fortran, Patch, pr67538, v1] ICE with invalid source allocation
2016-04-03 19:23 ` Jerry DeLisle
@ 2016-04-04 10:33 ` Andre Vehreschild
0 siblings, 0 replies; 3+ messages in thread
From: Andre Vehreschild @ 2016-04-04 10:33 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: GCC-Patches-ML, GCC-Fortran-ML
[-- Attachment #1: Type: text/plain, Size: 749 bytes --]
Hi Jerry,
thanks for the review. Committed as r234714.
Regards,
Andre
On Sun, 3 Apr 2016 12:23:08 -0700
Jerry DeLisle <jvdelisle@charter.net> wrote:
> On 04/03/2016 09:13 AM, Andre Vehreschild wrote:
> > Hi all,
> >
> > the attached patch checks that for F2008-style allocate(arr1, source=s)
> > the expression in s is array valued, when arr1 has no array spec and
> > emits an error message saying:
> >
> > Array specification or array-valued SOURCE= expression required in ALLOCATE statement at (1)
> >
> > This fixes the ICE.
> >
> > Bootstrapped and regtests ok on x86_64-linux-gnu/F23. Ok for trunk?
> >
> > Regards,
> > Andre
> >
>
> Yes, OK, thanks for patches.
>
> Jerry
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 2577 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 234712)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,5 +1,12 @@
2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+ PR fortran/67538
+ * resolve.c (resolve_allocate_expr): Emit error message when no
+ array spec and no array valued source= expression is given in an
+ F2008 allocate() for an array to allocate.
+
+2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+
PR fortran/65795
* trans-array.c (gfc_array_allocate): When the array is a coarray,
do not nullyfing its allocatable components in array_allocate, because
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (Revision 234712)
+++ gcc/fortran/resolve.c (Arbeitskopie)
@@ -7217,7 +7217,15 @@
if (!gfc_notify_std (GFC_STD_F2008, "Array specification required "
"in ALLOCATE statement at %L", &e->where))
goto failure;
- *array_alloc_wo_spec = true;
+ if (code->expr3->rank != 0)
+ *array_alloc_wo_spec = true;
+ else
+ {
+ gfc_error ("Array specification or array-valued SOURCE= "
+ "expression required in ALLOCATE statement at %L",
+ &e->where);
+ goto failure;
+ }
}
else
{
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 234712)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,5 +1,10 @@
2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+ PR fortran/67538
+ * gfortran.dg/allocate_with_source_19.f08: New test.
+
+2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+
PR fortran/65795
* gfortran.dg/coarray_allocate_6.f08: New test.
Index: gcc/testsuite/gfortran.dg/allocate_with_source_19.f08
===================================================================
--- gcc/testsuite/gfortran.dg/allocate_with_source_19.f08 (nicht existent)
+++ gcc/testsuite/gfortran.dg/allocate_with_source_19.f08 (Arbeitskopie)
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options -std=f2008 }
+
+! Contributed by mrestelli@gmail.com
+! Check that instead of an ICE the error message is emitted.
+
+module m
+ implicit none
+contains
+
+ subroutine s()
+ real, allocatable :: x(:)
+ real :: y
+
+ y = 5.0
+ ! x either needs an array spec, or y needs to be an array.
+ allocate( x , source=y ) ! { dg-error "Array specification or array-valued SOURCE= expression required in ALLOCATE statement" }
+
+ end subroutine s
+
+end module m
+
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-04 10:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-03 16:13 [Fortran, Patch, pr67538, v1] ICE with invalid source allocation Andre Vehreschild
2016-04-03 19:23 ` Jerry DeLisle
2016-04-04 10:33 ` Andre Vehreschild
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).