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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141518
138bc75d-0d04-0410-961f-
82ee72b054a4
+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>
PR fortran/35681
* fortran/arith.h: Update mpfr_to_mpz prototype.
* fortran/simplify.c (gfc_simplify_ceiling, gfc_simplify_floor,
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>
#include "gfortran.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 *****************/
/* Copy an array reference structure. */
gfc_expr *f;
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)
{
gfc_free_expr (f);
int flag_second_underscore;
int flag_implicit_none;
int flag_max_stack_var_size;
+ int flag_max_array_constructor;
int flag_range_check;
int flag_pack_derived;
int flag_repack_arrays;
@item Directory Options
@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
@xref{Link Options,,Options for influencing the linking step}.
@item Code Generation Options
@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
--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
-fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol
-finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan>} @gol
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}
@opindex @code{fmax-stack-var-size}
This option specifies the size in bytes of the largest array that will be put
Fortran RejectNegative Joined
-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=
Fortran RejectNegative Joined UInteger
-fmax-errors=<n> Maximum number of errors to report
gfc_option.max_continue_free = 255;
gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
gfc_option.max_subrecord_length = 0;
+ gfc_option.flag_max_array_constructor = 65535;
gfc_option.convert = GFC_CONVERT_NATIVE;
gfc_option.record_marker = 0;
gfc_option.dump_parse_tree = 0;
gfc_add_intrinsic_modules_path (arg);
break;
+ case OPT_fmax_array_constructor_:
+ gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
+ break;
+
case OPT_fmax_errors_:
gfc_option.max_errors = value;
break;
}
}
- /* The frontend should already have done any expansions possible
+ /* The frontend should already have done any expansions
at compile-time. */
if (!c->iterator)
{
if (c->iterator)
{
/* Problems occur when we get something like
- integer :: a(lots) = (/(i, i=1,lots)/) */
- /* TODO: Unexpanded array initializers. */
- internal_error
- ("Possible frontend bug: array constructor not expanded");
+ integer :: a(lots) = (/(i, i=1, lots)/) */
+ gfc_error_now ("The number of elements in the array constructor "
+ "at %L requires an increase of the allowed %d "
+ "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)
index = gfc_conv_mpz_to_tree (c->n.offset, gfc_index_integer_kind);