Commit 63346ddb by Steven G. Kargl Committed by Jerry DeLisle

re PR fortran/19925 (Implied do-loop in an initialization expression is broken)

2008-11-01  Steven G. Kargl  <kargls@comcast.net>

	PR fortran/19925
	* trans-array.c (gfc_trans_array_constructor_value): Fix comment.
	(gfc_conv_array_initializer): Convert internal_error() to gfc_error_now.
	* array.c: Remove GFC_MAX_AC_EXPAND macro.
	(gfc_expand_constructor): Use gfc_option.flag_max_array_constructor.
	* gfortran.h (gfc_option): Add flag_max_array_constructor member.
	* lang.opt: Add -fmax-array-constructor option.
	* expr.c (gfc_match_init_expr): Fix error message to mention new option.
	* invoke.texi: Document new option.
	* options.c (gfc_init_options): Set default value for new option.
	(gfc_handle_option): Deal with commandline.

From-SVN: r141518
parent fa4262a4
2008-11-01 Steven G. Kargl <kargls@comcast.net>
PR fortran/19925
* trans-array.c (gfc_trans_array_constructor_value): Fix comment.
(gfc_conv_array_initializer): Convert internal_error() to gfc_error_now.
* array.c: Remove GFC_MAX_AC_EXPAND macro.
(gfc_expand_constructor): Use gfc_option.flag_max_array_constructor.
* gfortran.h (gfc_option): Add flag_max_array_constructor member.
* lang.opt: Add -fmax-array-constructor option.
* expr.c (gfc_match_init_expr): Fix error message to mention new option.
* invoke.texi: Document new option.
* options.c (gfc_init_options): Set default value for new option.
(gfc_handle_option): Deal with commandline.
2008-11-01 Daniel Kraft <d@domob.eu> 2008-11-01 Daniel Kraft <d@domob.eu>
PR fortran/35681 PR fortran/35681
...@@ -72,7 +86,7 @@ ...@@ -72,7 +86,7 @@
* fortran/arith.h: Update mpfr_to_mpz prototype. * fortran/arith.h: Update mpfr_to_mpz prototype.
* fortran/simplify.c (gfc_simplify_ceiling, gfc_simplify_floor, * fortran/simplify.c (gfc_simplify_ceiling, gfc_simplify_floor,
gfc_simplify_ifix, gfc_simplify_idint, simplify_nint): Update function gfc_simplify_ifix, gfc_simplify_idint, simplify_nint): Update function
calls to include locus calls to include locus.
2008-10-30 Mikael Morin <mikael.morin@tele2.fr> 2008-10-30 Mikael Morin <mikael.morin@tele2.fr>
......
...@@ -24,13 +24,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -24,13 +24,6 @@ along with GCC; see the file COPYING3. If not see
#include "gfortran.h" #include "gfortran.h"
#include "match.h" #include "match.h"
/* This parameter is the size of the largest array constructor that we
will expand to an array constructor without iterators.
Constructors larger than this will remain in the iterator form. */
#define GFC_MAX_AC_EXPAND 65535
/**************** Array reference matching subroutines *****************/ /**************** Array reference matching subroutines *****************/
/* Copy an array reference structure. */ /* Copy an array reference structure. */
...@@ -1463,7 +1456,7 @@ gfc_expand_constructor (gfc_expr *e) ...@@ -1463,7 +1456,7 @@ gfc_expand_constructor (gfc_expr *e)
gfc_expr *f; gfc_expr *f;
gfc_try rc; gfc_try rc;
f = gfc_get_array_element (e, GFC_MAX_AC_EXPAND); f = gfc_get_array_element (e, gfc_option.flag_max_array_constructor);
if (f != NULL) if (f != NULL)
{ {
gfc_free_expr (f); gfc_free_expr (f);
......
...@@ -1992,6 +1992,7 @@ typedef struct ...@@ -1992,6 +1992,7 @@ typedef struct
int flag_second_underscore; int flag_second_underscore;
int flag_implicit_none; int flag_implicit_none;
int flag_max_stack_var_size; int flag_max_stack_var_size;
int flag_max_array_constructor;
int flag_range_check; int flag_range_check;
int flag_pack_derived; int flag_pack_derived;
int flag_repack_arrays; int flag_repack_arrays;
......
...@@ -148,7 +148,8 @@ and warnings}. ...@@ -148,7 +148,8 @@ and warnings}.
@item Directory Options @item Directory Options
@xref{Directory Options,,Options for directory search}. @xref{Directory Options,,Options for directory search}.
@gccoptlist{-I@var{dir} -J@var{dir} -M@var{dir} -fintrinsic-modules-path @var{dir}} @gccoptlist{-I@var{dir} -J@var{dir} -M@var{dir} @gol
-fintrinsic-modules-path @var{dir}}
@item Link Options @item Link Options
@xref{Link Options,,Options for influencing the linking step}. @xref{Link Options,,Options for influencing the linking step}.
...@@ -162,9 +163,10 @@ and warnings}. ...@@ -162,9 +163,10 @@ and warnings}.
@item Code Generation Options @item Code Generation Options
@xref{Code Gen Options,,Options for code generation conventions}. @xref{Code Gen Options,,Options for code generation conventions}.
@gccoptlist{-fno-automatic -ff2c -fno-underscoring @gccoptlist{-fno-automatic -ff2c -fno-underscoring @gol
-fsecond-underscore @gol -fsecond-underscore @gol
-fbounds-check -fcheck-array-temporaries -fmax-stack-var-size=@var{n} @gol -fbounds-check -fcheck-array-temporaries -fmax-array-constructor =@var{n} @gol
-fmax-stack-var-size=@var{n} @gol
-fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol -fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol
-fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol -fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol
-finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan>} @gol -finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan>} @gol
...@@ -1191,6 +1193,28 @@ sometimes useful in optimization, in order to avoid such temporaries. ...@@ -1191,6 +1193,28 @@ sometimes useful in optimization, in order to avoid such temporaries.
Note: The warning is only printed once per location. Note: The warning is only printed once per location.
@item -fmax-array-constructor=@var{n}
@opindex @code{fmax-array-constructor}
This option can be used to increase the upper limit permitted in
array constructors. The code below requires this option to expand
the array at compile time.
@smallexample
@code{program test}
@code{implicit none}
@code{integer j}
@code{integer, parameter :: n = 100000}
@code{integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)}
@code{print '(10(I0,1X))', i}
@code{end program test}
@end smallexample
@emph{Caution: This option can lead to long compile times and excessively
large object files.}
The default value for @var{n} is 65535.
@item -fmax-stack-var-size=@var{n} @item -fmax-stack-var-size=@var{n}
@opindex @code{fmax-stack-var-size} @opindex @code{fmax-stack-var-size}
This option specifies the size in bytes of the largest array that will be put This option specifies the size in bytes of the largest array that will be put
......
...@@ -284,6 +284,10 @@ finit-real= ...@@ -284,6 +284,10 @@ finit-real=
Fortran RejectNegative Joined Fortran RejectNegative Joined
-finit-real=<zero|nan|inf|-inf> Initialize local real variables -finit-real=<zero|nan|inf|-inf> Initialize local real variables
fmax-array-constructor=
Fortran RejectNegative Joined UInteger
-fmax-array-constructor=<n> Maximum number of objects in an array constructor
fmax-errors= fmax-errors=
Fortran RejectNegative Joined UInteger Fortran RejectNegative Joined UInteger
-fmax-errors=<n> Maximum number of errors to report -fmax-errors=<n> Maximum number of errors to report
......
...@@ -65,6 +65,7 @@ gfc_init_options (unsigned int argc, const char **argv) ...@@ -65,6 +65,7 @@ gfc_init_options (unsigned int argc, const char **argv)
gfc_option.max_continue_free = 255; gfc_option.max_continue_free = 255;
gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN; gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
gfc_option.max_subrecord_length = 0; gfc_option.max_subrecord_length = 0;
gfc_option.flag_max_array_constructor = 65535;
gfc_option.convert = GFC_CONVERT_NATIVE; gfc_option.convert = GFC_CONVERT_NATIVE;
gfc_option.record_marker = 0; gfc_option.record_marker = 0;
gfc_option.dump_parse_tree = 0; gfc_option.dump_parse_tree = 0;
...@@ -642,6 +643,10 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -642,6 +643,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_add_intrinsic_modules_path (arg); gfc_add_intrinsic_modules_path (arg);
break; break;
case OPT_fmax_array_constructor_:
gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
break;
case OPT_fmax_errors_: case OPT_fmax_errors_:
gfc_option.max_errors = value; gfc_option.max_errors = value;
break; break;
......
...@@ -1303,7 +1303,7 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, ...@@ -1303,7 +1303,7 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
} }
} }
/* The frontend should already have done any expansions possible /* The frontend should already have done any expansions
at compile-time. */ at compile-time. */
if (!c->iterator) if (!c->iterator)
{ {
...@@ -3946,10 +3946,13 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr) ...@@ -3946,10 +3946,13 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
if (c->iterator) if (c->iterator)
{ {
/* Problems occur when we get something like /* Problems occur when we get something like
integer :: a(lots) = (/(i, i=1,lots)/) */ integer :: a(lots) = (/(i, i=1, lots)/) */
/* TODO: Unexpanded array initializers. */ gfc_error_now ("The number of elements in the array constructor "
internal_error "at %L requires an increase of the allowed %d "
("Possible frontend bug: array constructor not expanded"); "upper limit. See -fmax-array-constructor "
"option", &expr->where,
gfc_option.flag_max_array_constructor);
return NULL_TREE;
} }
if (mpz_cmp_si (c->n.offset, 0) != 0) if (mpz_cmp_si (c->n.offset, 0) != 0)
index = gfc_conv_mpz_to_tree (c->n.offset, gfc_index_integer_kind); index = gfc_conv_mpz_to_tree (c->n.offset, gfc_index_integer_kind);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment