This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran] PR 44742 - Avoid ICE when -fmax-array-constructor is exeeded
- From: Tobias Burnus <burnus at net-b dot de>
- To: Jerry DeLisle <jvdelisle at verizon dot net>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 06 Jul 2010 23:52:35 +0200
- Subject: Re: [Patch, Fortran] PR 44742 - Avoid ICE when -fmax-array-constructor is exeeded
- References: <4C335569.1030201@net-b.de> <4C339305.7080309@verizon.net>
On 06.07.2010 22:33, Jerry DeLisle wrote:
> On 07/06/2010 09:10 AM, Tobias Burnus wrote:
>>
>> Build and currently regtesting on x86-64-linux.
>> OK for the trunk when it succeeded?
>>
>> * * *
>>
>> The patch (as posted in the PR) was approved by Jerry on IRC - I thus
>> intent to commit it after regtesting finished.
>
> Yes, OK and thanks for patch.
Actually, regtesting did not succeed as the code is now rejected during
parsing and not during resolution - thus the symbol itself it not
resolved. Therefore, any later usage gives now errors. I think that's OK
and thus I have committed the patch with the addition of two dg-errors
to initialization_2{0,4}.f90.
Committed as Rev. 161888 (cf. attachment).
Tobias
Tobias
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 161886)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,10 @@
+2010-07-06 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/44742
+ * gfortran.dg/parameter_array_init_6.f90: New.
+ * gfortran.dg/initialization_20.f90: Update dg-error.
+ * gfortran.dg/initialization_24.f90: Ditto.
+
2010-07-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/PR44693
* gfortran.dg/dim_range_1.f90: New test.
Index: gcc/testsuite/gfortran.dg/initialization_20.f90
===================================================================
--- gcc/testsuite/gfortran.dg/initialization_20.f90 (Revision 161886)
+++ gcc/testsuite/gfortran.dg/initialization_20.f90 (Arbeitskopie)
@@ -6,5 +6,5 @@
integer j
integer, parameter :: n = 100000
integer, parameter :: i(n)=(/(j,j=1,n)/) ! { dg-error "number of elements" }
- print *, i(5)
+ print *, i(5) ! { dg-error "has no IMPLICIT type" }
end program pr19925
Index: gcc/testsuite/gfortran.dg/initialization_24.f90
===================================================================
--- gcc/testsuite/gfortran.dg/initialization_24.f90 (Revision 161886)
+++ gcc/testsuite/gfortran.dg/initialization_24.f90 (Arbeitskopie)
@@ -3,7 +3,7 @@
! Test case by Dominique d'Humieres
INTEGER, PARAMETER ::N=65536
INTEGER, PARAMETER ::I(N)=(/(MOD(K,2),K=1,N)/)!{ dg-error "number of elements" }
-INTEGER, PARAMETER ::M(N)=I(N:1:-1)
+INTEGER, PARAMETER ::M(N)=I(N:1:-1) ! { dg-error "Syntax error in argument" }
print *, I(1), M(1), I(N), M(N)
END
Index: gcc/testsuite/gfortran.dg/parameter_array_init_6.f90
===================================================================
--- gcc/testsuite/gfortran.dg/parameter_array_init_6.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/parameter_array_init_6.f90 (Revision 0)
@@ -0,0 +1,18 @@
+! { dg-do compile }
+!
+! PR fortran/44742
+!
+! Test case based on Juergen Reuter's and reduced by
+! Janus Weil.
+!
+! The program creates a large array constructor, which
+! exceeds -fmax-array-constructor - and caused an ICE.
+!
+
+module proc8
+ implicit none
+ integer, parameter :: N = 256
+ logical, dimension(N**2), parameter :: A = .false.
+ logical, dimension(N,N), parameter :: B &
+ = reshape ( (/ A /), (/ N, N /) ) ! { dg-error "array constructor at .1. requires an increase" }
+end module
Index: gcc/fortran/array.c
===================================================================
--- gcc/fortran/array.c (Revision 161886)
+++ gcc/fortran/array.c (Arbeitskopie)
@@ -1545,7 +1545,7 @@
constructor if they are small enough. */
gfc_try
-gfc_expand_constructor (gfc_expr *e)
+gfc_expand_constructor (gfc_expr *e, bool fatal)
{
expand_info expand_save;
gfc_expr *f;
@@ -1557,6 +1557,15 @@
if (f != NULL)
{
gfc_free_expr (f);
+ if (fatal)
+ {
+ gfc_error ("The number of elements in the array constructor "
+ "at %L requires an increase of the allowed %d "
+ "upper limit. See -fmax-array-constructor "
+ "option", &e->where,
+ gfc_option.flag_max_array_constructor);
+ return FAILURE;
+ }
return SUCCESS;
}
Index: gcc/fortran/gfortran.h
===================================================================
--- gcc/fortran/gfortran.h (Revision 161886)
+++ gcc/fortran/gfortran.h (Arbeitskopie)
@@ -2715,7 +2715,7 @@
int gfc_compare_array_spec (gfc_array_spec *, gfc_array_spec *);
void gfc_simplify_iterator_var (gfc_expr *);
-gfc_try gfc_expand_constructor (gfc_expr *);
+gfc_try gfc_expand_constructor (gfc_expr *, bool);
int gfc_constant_ac (gfc_expr *);
int gfc_expanded_ac (gfc_expr *);
gfc_try gfc_resolve_character_array_constructor (gfc_expr *);
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 161886)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,5 +1,14 @@
2010-07-06 Tobias Burnus <burnus@net-b.de>
+ PR fortran/44742
+ * array.c (gfc_expand_constructor): Add optional diagnostic.
+ * gfortran.h (gfc_expand_constructor): Update prototype.
+ * expr.c (gfc_simplify_expr, check_init_expr,
+ gfc_reduce_init_expr): Update gfc_expand_constructor call.
+ * resolve.c (gfc_resolve_expr): Ditto.
+
+2010-07-06 Tobias Burnus <burnus@net-b.de>
+
* trans-decl.c: Include diagnostic-core.h besides toplev.h.
* trans-intrinsic.c: Ditto.
* trans-types.c: Ditto.
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (Revision 161886)
+++ gcc/fortran/expr.c (Arbeitskopie)
@@ -1894,7 +1894,7 @@
if (p->expr_type == EXPR_ARRAY && p->ref && p->ref->type == REF_ARRAY
&& p->ref->u.ar.type == AR_FULL)
- gfc_expand_constructor (p);
+ gfc_expand_constructor (p, false);
if (simplify_const_ref (p) == FAILURE)
return FAILURE;
@@ -2573,7 +2573,7 @@
if (t == FAILURE)
break;
- t = gfc_expand_constructor (e);
+ t = gfc_expand_constructor (e, true);
if (t == FAILURE)
break;
@@ -2609,7 +2609,7 @@
{
if (gfc_check_constructor_type (expr) == FAILURE)
return FAILURE;
- if (gfc_expand_constructor (expr) == FAILURE)
+ if (gfc_expand_constructor (expr, true) == FAILURE)
return FAILURE;
}
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (Revision 161886)
+++ gcc/fortran/resolve.c (Arbeitskopie)
@@ -5776,7 +5776,7 @@
{
expression_rank (e);
if (gfc_is_constant_expr (e) || gfc_is_expandable_expr (e))
- gfc_expand_constructor (e);
+ gfc_expand_constructor (e, false);
}
/* This provides the opportunity for the length of constructors with
@@ -5786,7 +5786,7 @@
{
/* For efficiency, we call gfc_expand_constructor for BT_CHARACTER
here rather then add a duplicate test for it above. */
- gfc_expand_constructor (e);
+ gfc_expand_constructor (e, false);
t = gfc_resolve_character_array_constructor (e);
}