Commit bdfd2ff0 by Thomas Koenig

re PR fortran/29952 (Flag to give runtime information " array temporary was created for argument")

2008-07-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/29952
	* gfortran.h:  Add "warn_array_temp" to gfc_option_t.
	* lang.opt:  Add -Warray-temporaries.
	* invoke.texi:  Document -Warray-temporaries
	* trans-array.h (gfc_trans_create_temp_array):  Add argument of
	type *locus.
	(gfc_conv_loop_setup):  Likewise.
	* trans-array.c (gfc_trans_create_temp_array):  If
	-Warray-temporaries is given and locus is present, warn about
	creation of array temporaries.
	(gfc_trans_array_constructor_subarray):  Add locus to call
	of gfc_conv_loop_setup.
	(gfc_trans_array_constructor):  Add where argument.  Pass where
	argument to call of gfc_trans_create_temp_array.
	(gfc_add_loop_ss_code):  Add where argument.  Pass where argument
	to recursive call of gfc_add_loop_ss_code and to call of
	gfc_trans_array_constructor.
	(gfc_conv_loop_setup):  Add where argument.  Pass where argument
	to calls to gfc_add_loop_ss_code and to gfc_trans_create_temp_array.
	(gfc_conv_expr_descriptor):  Pass location to call of
	gfc_conv_loop_setup.
	(gfc_conv_array_parameter):  If -Warray-temporaries is given,
	warn about creation of temporary arrays.
	* trans-expr.c (gfc_conv_subref_array_arg):  Add where argument
	to call to gfc_conv_loop_setup.
	(gfc_conv_function_call):  Add where argument to call to
	gfc_trans_creat_temp_array.
	(gfc_trans_subarray_assign):  Likewise.
	(gfc_trans_assignment_1):  Add where argument to call to
	gfc_conv_loop_setup.
	* trans-stmt.c (gfc_conv_elemental_dependencies):  Add where
	argument to call to gfc_trans_create_temp_array.
	(gfc_trans_call):  Add where argument to call to gfc_conv_loop_setup.
	(generate_loop_for_temp_to_lhs):  Likewise.
	(generate_loop_for_rhs_to_temp):  Likewise.
	(compute_inner_temp_size):  Likewise.
	(gfc_trans-pointer_assign_need_temp):  Likewise.
	(gfc_evaluate_where_mask):  Likewise.
	(gfc_trans_where_assign):  Likewise.
	(gfc_trans_where_3):  Likewise.
	* trans-io.c (transfer_srray_component):  Add where argument
	to function. Add where argument to call to gfc_conv_loop_setup.
	(transfer_expr):  Add where argument to call to
	transfer_array_component.
	(gfc_trans_transfer):  Add where expression to call to
	gfc_conv_loop_setup.
	* trans-intrinsic.c (gfc_conv_intrinsic_anyall):  Add
	where argument to call to gfc_conv_loop_setup.
	(gfc_conv_intrinsic_count):  Likewise.
	(gfc_conv_intrinsic_arith):  Likewise.
	(gfc_conv_intrinsic_dot_product):  Likewise.
	(gfc_conv_intrinsic_minmaxloc):  Likewise.
	(gfc_conv_intrinsic_minmaxval):  Likewise.
	(gfc_conv_intrinsic_array_transfer):  Warn about
	creation of temporary array.
	Add where argument to call to gfc_trans_create_temp_array.
	* options.c (gfc_init_options):  Initialize gfc_option.warn_array_temp.
	(gfc_handle_option):  Set gfc_option.warn_array_temp.

2008-07-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/29952
	* gfortran.dg/array_temporaries_1.f90: New test case.

From-SVN: r138112
parent f59a2f55
2008-07-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/29952
* gfortran.h: Add "warn_array_temp" to gfc_option_t.
* lang.opt: Add -Warray-temporaries.
* invoke.texi: Document -Warray-temporaries
* trans-array.h (gfc_trans_create_temp_array): Add argument of
type *locus.
(gfc_conv_loop_setup): Likewise.
* trans-array.c (gfc_trans_create_temp_array): If
-Warray-temporaries is given and locus is present, warn about
creation of array temporaries.
(gfc_trans_array_constructor_subarray): Add locus to call
of gfc_conv_loop_setup.
(gfc_trans_array_constructor): Add where argument. Pass where
argument to call of gfc_trans_create_temp_array.
(gfc_add_loop_ss_code): Add where argument. Pass where argument
to recursive call of gfc_add_loop_ss_code and to call of
gfc_trans_array_constructor.
(gfc_conv_loop_setup): Add where argument. Pass where argument
to calls to gfc_add_loop_ss_code and to gfc_trans_create_temp_array.
(gfc_conv_expr_descriptor): Pass location to call of
gfc_conv_loop_setup.
(gfc_conv_array_parameter): If -Warray-temporaries is given,
warn about creation of temporary arrays.
* trans-expr.c (gfc_conv_subref_array_arg): Add where argument
to call to gfc_conv_loop_setup.
(gfc_conv_function_call): Add where argument to call to
gfc_trans_creat_temp_array.
(gfc_trans_subarray_assign): Likewise.
(gfc_trans_assignment_1): Add where argument to call to
gfc_conv_loop_setup.
* trans-stmt.c (gfc_conv_elemental_dependencies): Add where
argument to call to gfc_trans_create_temp_array.
(gfc_trans_call): Add where argument to call to gfc_conv_loop_setup.
(generate_loop_for_temp_to_lhs): Likewise.
(generate_loop_for_rhs_to_temp): Likewise.
(compute_inner_temp_size): Likewise.
(gfc_trans-pointer_assign_need_temp): Likewise.
(gfc_evaluate_where_mask): Likewise.
(gfc_trans_where_assign): Likewise.
(gfc_trans_where_3): Likewise.
* trans-io.c (transfer_srray_component): Add where argument
to function. Add where argument to call to gfc_conv_loop_setup.
(transfer_expr): Add where argument to call to
transfer_array_component.
(gfc_trans_transfer): Add where expression to call to
gfc_conv_loop_setup.
* trans-intrinsic.c (gfc_conv_intrinsic_anyall): Add
where argument to call to gfc_conv_loop_setup.
(gfc_conv_intrinsic_count): Likewise.
(gfc_conv_intrinsic_arith): Likewise.
(gfc_conv_intrinsic_dot_product): Likewise.
(gfc_conv_intrinsic_minmaxloc): Likewise.
(gfc_conv_intrinsic_minmaxval): Likewise.
(gfc_conv_intrinsic_array_transfer): Warn about
creation of temporary array.
Add where argument to call to gfc_trans_create_temp_array.
* options.c (gfc_init_options): Initialize gfc_option.warn_array_temp.
(gfc_handle_option): Set gfc_option.warn_array_temp.
2008-07-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org> 2008-07-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 35058 PR 35058
......
...@@ -1873,6 +1873,7 @@ typedef struct ...@@ -1873,6 +1873,7 @@ typedef struct
int warn_tabs; int warn_tabs;
int warn_underflow; int warn_underflow;
int warn_character_truncation; int warn_character_truncation;
int warn_array_temp;
int max_errors; int max_errors;
int flag_all_intrinsics; int flag_all_intrinsics;
......
...@@ -137,9 +137,9 @@ by type. Explanations are in the following sections. ...@@ -137,9 +137,9 @@ by type. Explanations are in the following sections.
and warnings}. and warnings}.
@gccoptlist{-fmax-errors=@var{n} @gol @gccoptlist{-fmax-errors=@var{n} @gol
-fsyntax-only -pedantic -pedantic-errors @gol -fsyntax-only -pedantic -pedantic-errors @gol
-Wall -Waliasing -Wampersand -Wcharacter-truncation -Wconversion @gol -Wall -Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation @gol
-Wimplicit-interface -Wline-truncation -Wnonstd-intrinsics -Wsurprising @gol -Wconversion -Wimplicit-interface -Wline-truncation -Wnonstd-intrinsics @gol
-Wno-tabs -Wunderflow -Wunused-parameter} -Wsurprising -Wno-tabs -Wunderflow -Wunused-parameter}
@item Debugging Options @item Debugging Options
@xref{Debugging Options,,Options for debugging your program or GNU Fortran}. @xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
...@@ -698,6 +698,13 @@ given in a continued character constant, GNU Fortran assumes continuation ...@@ -698,6 +698,13 @@ given in a continued character constant, GNU Fortran assumes continuation
at the first non-comment, non-whitespace character after the ampersand at the first non-comment, non-whitespace character after the ampersand
that initiated the continuation. that initiated the continuation.
@item -Warray-temporaries
@opindex @code{Warray-temporaries}
@cindex warnings, array temporaries
Warn about array temporaries generated by the compiler. The information
generated by this warning is sometimes useful in optimization, in order to
avoid such temporaries.
@item -Wcharacter-truncation @item -Wcharacter-truncation
@opindex @code{Wcharacter-truncation} @opindex @code{Wcharacter-truncation}
@cindex warnings, character truncation @cindex warnings, character truncation
......
...@@ -76,6 +76,10 @@ Wampersand ...@@ -76,6 +76,10 @@ Wampersand
Fortran Warning Fortran Warning
Warn about missing ampersand in continued character constants Warn about missing ampersand in continued character constants
Warray-temporaries
Fortran Warning
Warn about creation of array temporaries
Wcharacter-truncation Wcharacter-truncation
Fortran Warning Fortran Warning
Warn about truncated character expressions Warn about truncated character expressions
......
...@@ -69,6 +69,7 @@ gfc_init_options (unsigned int argc, const char **argv) ...@@ -69,6 +69,7 @@ gfc_init_options (unsigned int argc, const char **argv)
gfc_option.warn_aliasing = 0; gfc_option.warn_aliasing = 0;
gfc_option.warn_ampersand = 0; gfc_option.warn_ampersand = 0;
gfc_option.warn_character_truncation = 0; gfc_option.warn_character_truncation = 0;
gfc_option.warn_array_temp = 0;
gfc_option.warn_conversion = 0; gfc_option.warn_conversion = 0;
gfc_option.warn_implicit_interface = 0; gfc_option.warn_implicit_interface = 0;
gfc_option.warn_line_truncation = 0; gfc_option.warn_line_truncation = 0;
...@@ -485,6 +486,10 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -485,6 +486,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_option.warn_ampersand = value; gfc_option.warn_ampersand = value;
break; break;
case OPT_Warray_temporaries:
gfc_option.warn_array_temp = value;
break;
case OPT_Wcharacter_truncation: case OPT_Wcharacter_truncation:
gfc_option.warn_character_truncation = value; gfc_option.warn_character_truncation = value;
break; break;
......
...@@ -576,7 +576,7 @@ tree ...@@ -576,7 +576,7 @@ tree
gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
gfc_loopinfo * loop, gfc_ss_info * info, gfc_loopinfo * loop, gfc_ss_info * info,
tree eltype, bool dynamic, bool dealloc, tree eltype, bool dynamic, bool dealloc,
bool callee_alloc) bool callee_alloc, locus * where)
{ {
tree type; tree type;
tree desc; tree desc;
...@@ -589,6 +589,10 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, ...@@ -589,6 +589,10 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
int dim; int dim;
gcc_assert (info->dimen > 0); gcc_assert (info->dimen > 0);
if (gfc_option.warn_array_temp && where)
gfc_warning ("Creating array temporary at %L", where);
/* Set the lower bound to zero. */ /* Set the lower bound to zero. */
for (dim = 0; dim < info->dimen; dim++) for (dim = 0; dim < info->dimen; dim++)
{ {
...@@ -1070,7 +1074,7 @@ gfc_trans_array_constructor_subarray (stmtblock_t * pblock, ...@@ -1070,7 +1074,7 @@ gfc_trans_array_constructor_subarray (stmtblock_t * pblock,
/* Initialize the loop. */ /* Initialize the loop. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
/* Make sure the constructed array has room for the new data. */ /* Make sure the constructed array has room for the new data. */
if (dynamic) if (dynamic)
...@@ -1683,7 +1687,7 @@ constant_array_constructor_loop_size (gfc_loopinfo * loop) ...@@ -1683,7 +1687,7 @@ constant_array_constructor_loop_size (gfc_loopinfo * loop)
simplest method. */ simplest method. */
static void static void
gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss) gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss, locus * where)
{ {
gfc_constructor *c; gfc_constructor *c;
tree offset; tree offset;
...@@ -1809,7 +1813,7 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss) ...@@ -1809,7 +1813,7 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss)
loopfrom = NULL_TREE; loopfrom = NULL_TREE;
gfc_trans_create_temp_array (&loop->pre, &loop->post, loop, &ss->data.info, gfc_trans_create_temp_array (&loop->pre, &loop->post, loop, &ss->data.info,
type, dynamic, true, false); type, dynamic, true, false, where);
if (loopfrom != NULL_TREE) if (loopfrom != NULL_TREE)
{ {
...@@ -1896,7 +1900,8 @@ gfc_set_vector_loop_bounds (gfc_loopinfo * loop, gfc_ss_info * info) ...@@ -1896,7 +1900,8 @@ gfc_set_vector_loop_bounds (gfc_loopinfo * loop, gfc_ss_info * info)
but before the actual scalarizing loops. */ but before the actual scalarizing loops. */
static void static void
gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript) gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
locus * where)
{ {
gfc_se se; gfc_se se;
int n; int n;
...@@ -1950,7 +1955,8 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript) ...@@ -1950,7 +1955,8 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript)
/* Add the expressions for scalar and vector subscripts. */ /* Add the expressions for scalar and vector subscripts. */
for (n = 0; n < GFC_MAX_DIMENSIONS; n++) for (n = 0; n < GFC_MAX_DIMENSIONS; n++)
if (ss->data.info.subscript[n]) if (ss->data.info.subscript[n])
gfc_add_loop_ss_code (loop, ss->data.info.subscript[n], true); gfc_add_loop_ss_code (loop, ss->data.info.subscript[n], true,
where);
gfc_set_vector_loop_bounds (loop, &ss->data.info); gfc_set_vector_loop_bounds (loop, &ss->data.info);
break; break;
...@@ -1993,7 +1999,7 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript) ...@@ -1993,7 +1999,7 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript)
gfc_add_block_to_block (&loop->pre, &se.pre); gfc_add_block_to_block (&loop->pre, &se.pre);
gfc_add_block_to_block (&loop->post, &se.post); gfc_add_block_to_block (&loop->post, &se.post);
} }
gfc_trans_array_constructor (loop, ss); gfc_trans_array_constructor (loop, ss, where);
break; break;
case GFC_SS_TEMP: case GFC_SS_TEMP:
...@@ -3327,7 +3333,7 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest, ...@@ -3327,7 +3333,7 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest,
moved outside the loop. */ moved outside the loop. */
void void
gfc_conv_loop_setup (gfc_loopinfo * loop) gfc_conv_loop_setup (gfc_loopinfo * loop, locus * where)
{ {
int n; int n;
int dim; int dim;
...@@ -3493,7 +3499,7 @@ gfc_conv_loop_setup (gfc_loopinfo * loop) ...@@ -3493,7 +3499,7 @@ gfc_conv_loop_setup (gfc_loopinfo * loop)
/* Add all the scalar code that can be taken out of the loops. /* Add all the scalar code that can be taken out of the loops.
This may include calculating the loop bounds, so do it before This may include calculating the loop bounds, so do it before
allocating the temporary. */ allocating the temporary. */
gfc_add_loop_ss_code (loop, loop->ss, false); gfc_add_loop_ss_code (loop, loop->ss, false, where);
/* If we want a temporary then create it. */ /* If we want a temporary then create it. */
if (loop->temp_ss != NULL) if (loop->temp_ss != NULL)
...@@ -3515,7 +3521,7 @@ gfc_conv_loop_setup (gfc_loopinfo * loop) ...@@ -3515,7 +3521,7 @@ gfc_conv_loop_setup (gfc_loopinfo * loop)
loop->temp_ss->data.info.dimen = n; loop->temp_ss->data.info.dimen = n;
gfc_trans_create_temp_array (&loop->pre, &loop->post, loop, gfc_trans_create_temp_array (&loop->pre, &loop->post, loop,
&loop->temp_ss->data.info, tmp, false, true, &loop->temp_ss->data.info, tmp, false, true,
false); false, where);
} }
for (n = 0; n < loop->temp_dim; n++) for (n = 0; n < loop->temp_dim; n++)
...@@ -4299,6 +4305,9 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) ...@@ -4299,6 +4305,9 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
stmt_unpacked = build_call_expr (gfor_fndecl_in_pack, 1, tmp); stmt_unpacked = build_call_expr (gfor_fndecl_in_pack, 1, tmp);
stride = gfc_index_one_node; stride = gfc_index_one_node;
if (gfc_option.warn_array_temp)
gfc_warning ("Creating array temporary at %L", &loc);
} }
/* This is for the case where the array data is used directly without /* This is for the case where the array data is used directly without
...@@ -4871,7 +4880,7 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) ...@@ -4871,7 +4880,7 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
gfc_add_ss_to_loop (&loop, loop.temp_ss); gfc_add_ss_to_loop (&loop, loop.temp_ss);
} }
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, & expr->where);
if (need_tmp) if (need_tmp)
{ {
...@@ -5219,6 +5228,10 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77) ...@@ -5219,6 +5228,10 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77)
{ {
desc = se->expr; desc = se->expr;
/* Repack the array. */ /* Repack the array. */
if (gfc_option.warn_array_temp)
gfc_warning ("Creating array temporary at %L", &expr->where);
ptr = build_call_expr (gfor_fndecl_in_pack, 1, desc); ptr = build_call_expr (gfor_fndecl_in_pack, 1, desc);
ptr = gfc_evaluate_now (ptr, &se->pre); ptr = gfc_evaluate_now (ptr, &se->pre);
se->expr = ptr; se->expr = ptr;
......
...@@ -32,7 +32,8 @@ void gfc_set_loop_bounds_from_array_spec (gfc_interface_mapping *, ...@@ -32,7 +32,8 @@ void gfc_set_loop_bounds_from_array_spec (gfc_interface_mapping *,
/* Generate code to create a temporary array. */ /* Generate code to create a temporary array. */
tree gfc_trans_create_temp_array (stmtblock_t *, stmtblock_t *, gfc_loopinfo *, tree gfc_trans_create_temp_array (stmtblock_t *, stmtblock_t *, gfc_loopinfo *,
gfc_ss_info *, tree, bool, bool, bool); gfc_ss_info *, tree, bool, bool, bool,
locus *);
/* Generate function entry code for allocation of compiler allocated array /* Generate function entry code for allocation of compiler allocated array
variables. */ variables. */
...@@ -88,7 +89,7 @@ void gfc_trans_scalarizing_loops (gfc_loopinfo *, stmtblock_t *); ...@@ -88,7 +89,7 @@ void gfc_trans_scalarizing_loops (gfc_loopinfo *, stmtblock_t *);
/* Mark the end of the main loop body and the start of the copying loop. */ /* Mark the end of the main loop body and the start of the copying loop. */
void gfc_trans_scalarized_loop_boundary (gfc_loopinfo *, stmtblock_t *); void gfc_trans_scalarized_loop_boundary (gfc_loopinfo *, stmtblock_t *);
/* Initialize the scalarization loop parameters. */ /* Initialize the scalarization loop parameters. */
void gfc_conv_loop_setup (gfc_loopinfo *); void gfc_conv_loop_setup (gfc_loopinfo *, locus *);
/* Resolve array assignment dependencies. */ /* Resolve array assignment dependencies. */
void gfc_conv_resolve_dependencies (gfc_loopinfo *, gfc_ss *, gfc_ss *); void gfc_conv_resolve_dependencies (gfc_loopinfo *, gfc_ss *, gfc_ss *);
/* Build a null array descriptor constructor. */ /* Build a null array descriptor constructor. */
......
...@@ -2059,7 +2059,7 @@ gfc_conv_subref_array_arg (gfc_se * parmse, gfc_expr * expr, ...@@ -2059,7 +2059,7 @@ gfc_conv_subref_array_arg (gfc_se * parmse, gfc_expr * expr,
gfc_add_ss_to_loop (&loop, loop.temp_ss); gfc_add_ss_to_loop (&loop, loop.temp_ss);
/* Setup the scalarizing loops. */ /* Setup the scalarizing loops. */
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
/* Pass the temporary descriptor back to the caller. */ /* Pass the temporary descriptor back to the caller. */
info = &loop.temp_ss->data.info; info = &loop.temp_ss->data.info;
...@@ -2124,7 +2124,7 @@ gfc_conv_subref_array_arg (gfc_se * parmse, gfc_expr * expr, ...@@ -2124,7 +2124,7 @@ gfc_conv_subref_array_arg (gfc_se * parmse, gfc_expr * expr,
gfc_conv_ss_startstride (&loop2); gfc_conv_ss_startstride (&loop2);
/* Setup the scalarizing loops. */ /* Setup the scalarizing loops. */
gfc_conv_loop_setup (&loop2); gfc_conv_loop_setup (&loop2, &expr->where);
gfc_copy_loopinfo_to_se (&lse, &loop2); gfc_copy_loopinfo_to_se (&lse, &loop2);
gfc_copy_loopinfo_to_se (&rse, &loop2); gfc_copy_loopinfo_to_se (&rse, &loop2);
...@@ -2717,7 +2717,8 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, ...@@ -2717,7 +2717,8 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
mustn't be deallocated. */ mustn't be deallocated. */
callee_alloc = sym->attr.allocatable || sym->attr.pointer; callee_alloc = sym->attr.allocatable || sym->attr.pointer;
gfc_trans_create_temp_array (&se->pre, &se->post, se->loop, info, tmp, gfc_trans_create_temp_array (&se->pre, &se->post, se->loop, info, tmp,
false, !sym->attr.pointer, callee_alloc); false, !sym->attr.pointer, callee_alloc,
&se->ss->expr->where);
/* Pass the temporary as the first argument. */ /* Pass the temporary as the first argument. */
tmp = info->descriptor; tmp = info->descriptor;
...@@ -3335,7 +3336,7 @@ gfc_trans_subarray_assign (tree dest, gfc_component * cm, gfc_expr * expr) ...@@ -3335,7 +3336,7 @@ gfc_trans_subarray_assign (tree dest, gfc_component * cm, gfc_expr * expr)
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
/* Setup the scalarizing loops. */ /* Setup the scalarizing loops. */
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
/* Setup the gfc_se structures. */ /* Setup the gfc_se structures. */
gfc_copy_loopinfo_to_se (&lse, &loop); gfc_copy_loopinfo_to_se (&lse, &loop);
...@@ -4415,7 +4416,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag) ...@@ -4415,7 +4416,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag)
/* Resolve any data dependencies in the statement. */ /* Resolve any data dependencies in the statement. */
gfc_conv_resolve_dependencies (&loop, lss, rss); gfc_conv_resolve_dependencies (&loop, lss, rss);
/* Setup the scalarizing loops. */ /* Setup the scalarizing loops. */
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr2->where);
/* Setup the gfc_se structures. */ /* Setup the gfc_se structures. */
gfc_copy_loopinfo_to_se (&lse, &loop); gfc_copy_loopinfo_to_se (&lse, &loop);
......
...@@ -1731,7 +1731,7 @@ gfc_conv_intrinsic_anyall (gfc_se * se, gfc_expr * expr, int op) ...@@ -1731,7 +1731,7 @@ gfc_conv_intrinsic_anyall (gfc_se * se, gfc_expr * expr, int op)
/* Initialize the loop. */ /* Initialize the loop. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
gfc_mark_ss_chain_used (arrayss, 1); gfc_mark_ss_chain_used (arrayss, 1);
/* Generate the loop body. */ /* Generate the loop body. */
...@@ -1813,7 +1813,7 @@ gfc_conv_intrinsic_count (gfc_se * se, gfc_expr * expr) ...@@ -1813,7 +1813,7 @@ gfc_conv_intrinsic_count (gfc_se * se, gfc_expr * expr)
/* Initialize the loop. */ /* Initialize the loop. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
gfc_mark_ss_chain_used (arrayss, 1); gfc_mark_ss_chain_used (arrayss, 1);
/* Generate the loop body. */ /* Generate the loop body. */
...@@ -1901,7 +1901,7 @@ gfc_conv_intrinsic_arith (gfc_se * se, gfc_expr * expr, int op) ...@@ -1901,7 +1901,7 @@ gfc_conv_intrinsic_arith (gfc_se * se, gfc_expr * expr, int op)
/* Initialize the loop. */ /* Initialize the loop. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
gfc_mark_ss_chain_used (arrayss, 1); gfc_mark_ss_chain_used (arrayss, 1);
if (maskss) if (maskss)
...@@ -2019,7 +2019,7 @@ gfc_conv_intrinsic_dot_product (gfc_se * se, gfc_expr * expr) ...@@ -2019,7 +2019,7 @@ gfc_conv_intrinsic_dot_product (gfc_se * se, gfc_expr * expr)
/* Initialize the loop. */ /* Initialize the loop. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
gfc_mark_ss_chain_used (arrayss1, 1); gfc_mark_ss_chain_used (arrayss1, 1);
gfc_mark_ss_chain_used (arrayss2, 1); gfc_mark_ss_chain_used (arrayss2, 1);
...@@ -2159,7 +2159,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, int op) ...@@ -2159,7 +2159,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, int op)
/* Initialize the loop. */ /* Initialize the loop. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
gcc_assert (loop.dimen == 1); gcc_assert (loop.dimen == 1);
...@@ -2355,7 +2355,7 @@ gfc_conv_intrinsic_minmaxval (gfc_se * se, gfc_expr * expr, int op) ...@@ -2355,7 +2355,7 @@ gfc_conv_intrinsic_minmaxval (gfc_se * se, gfc_expr * expr, int op)
/* Initialize the loop. */ /* Initialize the loop. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr->where);
gfc_mark_ss_chain_used (arrayss, 1); gfc_mark_ss_chain_used (arrayss, 1);
if (maskss) if (maskss)
...@@ -3434,6 +3434,10 @@ gfc_conv_intrinsic_array_transfer (gfc_se * se, gfc_expr * expr) ...@@ -3434,6 +3434,10 @@ gfc_conv_intrinsic_array_transfer (gfc_se * se, gfc_expr * expr)
&& arg->expr->ref->u.ar.type == AR_FULL)) && arg->expr->ref->u.ar.type == AR_FULL))
{ {
tmp = build_fold_addr_expr (argse.expr); tmp = build_fold_addr_expr (argse.expr);
if (gfc_option.warn_array_temp)
gfc_warning ("Creating array temporary at %L", &expr->where);
source = build_call_expr (gfor_fndecl_in_pack, 1, tmp); source = build_call_expr (gfor_fndecl_in_pack, 1, tmp);
source = gfc_evaluate_now (source, &argse.pre); source = gfc_evaluate_now (source, &argse.pre);
...@@ -3587,7 +3591,8 @@ gfc_conv_intrinsic_array_transfer (gfc_se * se, gfc_expr * expr) ...@@ -3587,7 +3591,8 @@ gfc_conv_intrinsic_array_transfer (gfc_se * se, gfc_expr * expr)
FIXME callee_alloc is not set! */ FIXME callee_alloc is not set! */
gfc_trans_create_temp_array (&se->pre, &se->post, se->loop, gfc_trans_create_temp_array (&se->pre, &se->post, se->loop,
info, mold_type, false, true, false); info, mold_type, false, true, false,
&expr->where);
/* Cast the pointer to the result. */ /* Cast the pointer to the result. */
tmp = gfc_conv_descriptor_data_get (info->descriptor); tmp = gfc_conv_descriptor_data_get (info->descriptor);
......
...@@ -1900,7 +1900,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code); ...@@ -1900,7 +1900,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code);
recursive. */ recursive. */
static tree static tree
transfer_array_component (tree expr, gfc_component * cm) transfer_array_component (tree expr, gfc_component * cm, locus * where)
{ {
tree tmp; tree tmp;
stmtblock_t body; stmtblock_t body;
...@@ -1944,7 +1944,7 @@ transfer_array_component (tree expr, gfc_component * cm) ...@@ -1944,7 +1944,7 @@ transfer_array_component (tree expr, gfc_component * cm)
gfc_init_loopinfo (&loop); gfc_init_loopinfo (&loop);
gfc_add_ss_to_loop (&loop, ss); gfc_add_ss_to_loop (&loop, ss);
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, where);
gfc_mark_ss_chain_used (ss, 1); gfc_mark_ss_chain_used (ss, 1);
gfc_start_scalarized_body (&loop, &body); gfc_start_scalarized_body (&loop, &body);
...@@ -2089,7 +2089,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) ...@@ -2089,7 +2089,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code)
if (c->dimension) if (c->dimension)
{ {
tmp = transfer_array_component (tmp, c); tmp = transfer_array_component (tmp, c, & code->loc);
gfc_add_expr_to_block (&se->pre, tmp); gfc_add_expr_to_block (&se->pre, tmp);
} }
else else
...@@ -2213,7 +2213,7 @@ gfc_trans_transfer (gfc_code * code) ...@@ -2213,7 +2213,7 @@ gfc_trans_transfer (gfc_code * code)
/* Initialize the loop. */ /* Initialize the loop. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &code->expr->where);
/* The main loop body. */ /* The main loop body. */
gfc_mark_ss_chain_used (ss, 1); gfc_mark_ss_chain_used (ss, 1);
......
...@@ -269,7 +269,8 @@ gfc_conv_elemental_dependencies (gfc_se * se, gfc_se * loopse, ...@@ -269,7 +269,8 @@ gfc_conv_elemental_dependencies (gfc_se * se, gfc_se * loopse,
tmp = gfc_typenode_for_spec (&e->ts); tmp = gfc_typenode_for_spec (&e->ts);
tmp = gfc_trans_create_temp_array (&se->pre, &se->post, tmp = gfc_trans_create_temp_array (&se->pre, &se->post,
&tmp_loop, info, tmp, &tmp_loop, info, tmp,
false, true, false); false, true, false,
& arg->expr->where);
gfc_add_modify_expr (&se->pre, size, tmp); gfc_add_modify_expr (&se->pre, size, tmp);
tmp = fold_convert (pvoid_type_node, info->data); tmp = fold_convert (pvoid_type_node, info->data);
gfc_add_modify_expr (&se->pre, data, tmp); gfc_add_modify_expr (&se->pre, data, tmp);
...@@ -375,7 +376,7 @@ gfc_trans_call (gfc_code * code, bool dependency_check) ...@@ -375,7 +376,7 @@ gfc_trans_call (gfc_code * code, bool dependency_check)
gfc_add_ss_to_loop (&loop, ss); gfc_add_ss_to_loop (&loop, ss);
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &code->expr->where);
gfc_mark_ss_chain_used (ss, 1); gfc_mark_ss_chain_used (ss, 1);
/* Convert the arguments, checking for dependencies. */ /* Convert the arguments, checking for dependencies. */
...@@ -1977,7 +1978,7 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3, ...@@ -1977,7 +1978,7 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3,
/* Calculate the bounds of the scalarization. */ /* Calculate the bounds of the scalarization. */
gfc_conv_ss_startstride (&loop1); gfc_conv_ss_startstride (&loop1);
/* Setup the scalarizing loops. */ /* Setup the scalarizing loops. */
gfc_conv_loop_setup (&loop1); gfc_conv_loop_setup (&loop1, &expr->where);
gfc_mark_ss_chain_used (lss, 1); gfc_mark_ss_chain_used (lss, 1);
...@@ -2075,7 +2076,7 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3, ...@@ -2075,7 +2076,7 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3,
gfc_add_ss_to_loop (&loop, rss); gfc_add_ss_to_loop (&loop, rss);
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr2->where);
gfc_mark_ss_chain_used (rss, 1); gfc_mark_ss_chain_used (rss, 1);
/* Start the loop body. */ /* Start the loop body. */
...@@ -2197,7 +2198,7 @@ compute_inner_temp_size (gfc_expr *expr1, gfc_expr *expr2, ...@@ -2197,7 +2198,7 @@ compute_inner_temp_size (gfc_expr *expr1, gfc_expr *expr2,
flag_bounds_check = 0; flag_bounds_check = 0;
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
flag_bounds_check = save_flag; flag_bounds_check = save_flag;
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr2->where);
/* Figure out how many elements we need. */ /* Figure out how many elements we need. */
for (i = 0; i < loop.dimen; i++) for (i = 0; i < loop.dimen; i++)
...@@ -2538,7 +2539,7 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, ...@@ -2538,7 +2539,7 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
/* Setup the scalarizing loops and bounds. */ /* Setup the scalarizing loops and bounds. */
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr2->where);
info = &rss->data.info; info = &rss->data.info;
desc = info->descriptor; desc = info->descriptor;
...@@ -3019,7 +3020,7 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info, ...@@ -3019,7 +3020,7 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info,
gfc_add_ss_to_loop (&loop, rss); gfc_add_ss_to_loop (&loop, rss);
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &me->where);
gfc_mark_ss_chain_used (rss, 1); gfc_mark_ss_chain_used (rss, 1);
/* Start the loop body. */ /* Start the loop body. */
...@@ -3186,7 +3187,7 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, ...@@ -3186,7 +3187,7 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
gfc_conv_resolve_dependencies (&loop, lss_section, rss); gfc_conv_resolve_dependencies (&loop, lss_section, rss);
/* Setup the scalarizing loops. */ /* Setup the scalarizing loops. */
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &expr2->where);
/* Setup the gfc_se structures. */ /* Setup the gfc_se structures. */
gfc_copy_loopinfo_to_se (&lse, &loop); gfc_copy_loopinfo_to_se (&lse, &loop);
...@@ -3634,7 +3635,7 @@ gfc_trans_where_3 (gfc_code * cblock, gfc_code * eblock) ...@@ -3634,7 +3635,7 @@ gfc_trans_where_3 (gfc_code * cblock, gfc_code * eblock)
} }
gfc_conv_ss_startstride (&loop); gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop); gfc_conv_loop_setup (&loop, &tdst->where);
gfc_mark_ss_chain_used (css, 1); gfc_mark_ss_chain_used (css, 1);
gfc_mark_ss_chain_used (tdss, 1); gfc_mark_ss_chain_used (tdss, 1);
......
2008-07-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/29952
* gfortran.dg/array_temporaries_1.f90: New test case.
2008-07-23 Ian Lance Taylor <iant@google.com> 2008-07-23 Ian Lance Taylor <iant@google.com>
* gcc.target/i386/20080723-1.c: New test. * gcc.target/i386/20080723-1.c: New test.
......
! { dg-do compile }
! { dg-options "-Warray-temporaries" }
subroutine bar(a)
real, dimension(2) :: a
end
program main
integer, parameter :: n=3
integer :: i
real, dimension(n) :: a, b
a = 0.2
i = 2
a(i:i+1) = a(1:2) ! { dg-warning "Creating array temporary" }
a = cshift(a,1) ! { dg-warning "Creating array temporary" }
b = cshift(a,1)
call bar(a(1:3:2)) ! { dg-warning "Creating array temporary" }
end program main
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