aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/f95-lang.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-07-01 22:52:54 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-07-01 22:52:54 +0200
commit79a592e33e39e2a7d7c2f6180e963074908a15a7 (patch)
treea3ddb9cca844feca67466281ebedca4796fe9577 /gcc/fortran/f95-lang.c
parente2298656eb195614bcf70e385ddf44a4b137a081 (diff)
downloadgcc-79a592e33e39e2a7d7c2f6180e963074908a15a7.zip
gcc-79a592e33e39e2a7d7c2f6180e963074908a15a7.tar.gz
gcc-79a592e33e39e2a7d7c2f6180e963074908a15a7.tar.bz2
re PR fortran/71687 (ICE in omp_add_variable, at gimplify.c:5821)
PR fortran/71687 * f95-lang.c (struct binding_level): Add reversed field. (clear_binding_level): Adjust initializer. (getdecls): If reversed is clear, set it and nreverse the names chain before returning it. (poplevel): Use getdecls. * trans-decl.c (gfc_generate_function_code, gfc_process_block_locals): Use nreverse to pushdecl decls in the declaration order. * gfortran.dg/gomp/pr71687.f90: New test. From-SVN: r237926
Diffstat (limited to 'gcc/fortran/f95-lang.c')
-rw-r--r--gcc/fortran/f95-lang.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index 5849073..2b58173 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -286,6 +286,9 @@ binding_level {
tree blocks;
/* The binding level containing this one (the enclosing binding level). */
struct binding_level *level_chain;
+ /* True if nreverse has been already called on names; if false, names
+ are ordered from newest declaration to oldest one. */
+ bool reversed;
};
/* The binding level currently in effect. */
@@ -296,7 +299,7 @@ static GTY(()) struct binding_level *current_binding_level = NULL;
static GTY(()) struct binding_level *global_binding_level;
/* Binding level structures are initialized by copying this one. */
-static struct binding_level clear_binding_level = { NULL, NULL, NULL };
+static struct binding_level clear_binding_level = { NULL, NULL, NULL, false };
/* Return true if we are in the global binding level. */
@@ -310,6 +313,11 @@ global_bindings_p (void)
tree
getdecls (void)
{
+ if (!current_binding_level->reversed)
+ {
+ current_binding_level->reversed = true;
+ current_binding_level->names = nreverse (current_binding_level->names);
+ }
return current_binding_level->names;
}
@@ -347,7 +355,7 @@ poplevel (int keep, int functionbody)
binding level that we are about to exit and which is returned by this
routine. */
tree block_node = NULL_TREE;
- tree decl_chain = current_binding_level->names;
+ tree decl_chain = getdecls ();
tree subblock_chain = current_binding_level->blocks;
tree subblock_node;