This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/29458] Spurious -Wuninitialized warning for implied do-loop counter
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jan 2008 19:53:30 -0000
- Subject: [Bug fortran/29458] Spurious -Wuninitialized warning for implied do-loop counter
- References: <bug-29458-10259@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from manu at gcc dot gnu dot org 2008-01-30 19:53 -------
I tried this:
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (revision 131893)
+++ gcc/fortran/trans-array.c (working copy)
@@ -1246,36 +1246,27 @@ gfc_trans_array_constructor_value (stmtb
tree end;
tree step;
tree loopvar;
tree exit_label;
tree loopbody;
- tree tmp2;
- tree tmp_loopvar;
loopbody = gfc_finish_block (&body);
if (c->iterator->var->symtree->n.sym->backend_decl)
{
- gfc_init_se (&se, NULL);
- gfc_conv_expr (&se, c->iterator->var);
- gfc_add_block_to_block (pblock, &se.pre);
- loopvar = se.expr;
+ loopvar = gfc_typenode_for_spec (&c->iterator->var->ts);
+ loopvar = gfc_create_var (loopvar,
c->iterator->var->symtree->n.sym->name);
}
else
{
/* If the iterator appears in a specification expression in
an interface mapping, we need to make a temp for the loop
variable because it is not declared locally. */
loopvar = gfc_typenode_for_spec (&c->iterator->var->ts);
loopvar = gfc_create_var (loopvar, "loopvar");
}
- /* Make a temporary, store the current value in that
- and return it, once the loop is done. */
- tmp_loopvar = gfc_create_var (TREE_TYPE (loopvar), "loopvar");
- gfc_add_modify_expr (pblock, tmp_loopvar, loopvar);
-
/* Initialize the loop. */
gfc_init_se (&se, NULL);
gfc_conv_expr_val (&se, c->iterator->start);
gfc_add_block_to_block (pblock, &se.pre);
gfc_add_modify_expr (pblock, loopvar, se.expr);
@@ -1293,10 +1284,12 @@ gfc_trans_array_constructor_value (stmtb
/* If this array expands dynamically, and the number of iterations
is not constant, we won't have allocated space for the static
part of C->EXPR's size. Do that now. */
if (dynamic && gfc_iterator_has_dynamic_bounds (c->iterator))
{
+ tree tmp2;
+
/* Get the number of iterations. */
tmp = gfc_get_iteration_count (loopvar, end, step);
/* Get the static part of C->EXPR's size. */
gfc_get_array_constructor_element_size (&size, c->expr);
@@ -1339,13 +1332,10 @@ gfc_trans_array_constructor_value (stmtb
gfc_add_expr_to_block (pblock, tmp);
/* Add the exit label. */
tmp = build1_v (LABEL_EXPR, exit_label);
gfc_add_expr_to_block (pblock, tmp);
-
- /* Restore the original value of the loop counter. */
- gfc_add_modify_expr (pblock, loopvar, tmp_loopvar);
}
}
mpz_clear (size);
}
But something is still using the wrong 'i':
<D.937>:;
if (i.4D.918 > D.919)
{
goto L.1D.922;
}
else
{
}
D.932 = atmp.2D.915.dataD.906;
D.938 = (integer(kind=4)D.8[0] *) D.932;
offset.6D.939 = offset.3D.917;
(*D.938)[offset.6D.939] = iD.902; <<===== This is the wrong "i"!!
offset.3D.917 = offset.3D.917 + 1;
i.4D.918 = i.4D.918 + 1;
goto <D.937>;
I also give up. Too time-consuming understanding what is going on...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29458