aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/parse.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@gcc.gnu.org>2016-10-27 21:55:12 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-10-27 21:55:12 +0200
commit6f21288f8c3579ec7ae47615e76ba1e6ad25551f (patch)
tree8eace66a9ed3bade23fd586a126fba2b7fcd0e9f /gcc/fortran/parse.c
parent47ffb5d95eb5c5514dae306b7c8e4308f1f001a2 (diff)
downloadgcc-6f21288f8c3579ec7ae47615e76ba1e6ad25551f.zip
gcc-6f21288f8c3579ec7ae47615e76ba1e6ad25551f.tar.gz
gcc-6f21288f8c3579ec7ae47615e76ba1e6ad25551f.tar.bz2
re PR fortran/78026 (ICE in gfc_resolve_omp_declare_simd, at fortran/openmp.c:5190)
PR fortran/78026 * parse.c (decode_statement): Don't create namespace for possible select type here and destroy it afterwards. (parse_select_type_block): Set gfc_current_ns to new_st.ext.block.ns. (parse_executable, gfc_parse_file): Formatting fixes. * match.c (gfc_match_select_type): Create namespace for select type here, only after matching select type. Formatting fixes. Free that namespace if not returning MATCH_YES, after gfc_undo_symbols, otherwise remember it in new_st.ext.block.ns and switch to parent namespace anyway. * gfortran.dg/gomp/pr78026.f03: New test. * gfortran.dg/select_type_38.f03: New test. From-SVN: r241630
Diffstat (limited to 'gcc/fortran/parse.c')
-rw-r--r--gcc/fortran/parse.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 760d3af..2aa2afc 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -295,7 +295,6 @@ static bool in_specification_block;
static gfc_statement
decode_statement (void)
{
- gfc_namespace *ns;
gfc_statement st;
locus old_locus;
match m = MATCH_NO;
@@ -424,12 +423,7 @@ decode_statement (void)
match (NULL, gfc_match_associate, ST_ASSOCIATE);
match (NULL, gfc_match_critical, ST_CRITICAL);
match (NULL, gfc_match_select, ST_SELECT_CASE);
-
- gfc_current_ns = gfc_build_block_ns (gfc_current_ns);
match (NULL, gfc_match_select_type, ST_SELECT_TYPE);
- ns = gfc_current_ns;
- gfc_current_ns = gfc_current_ns->parent;
- gfc_free_namespace (ns);
/* General statement matching: Instead of testing every possible
statement, we eliminate most possibilities by peeking at the
@@ -4103,6 +4097,7 @@ parse_select_type_block (void)
gfc_code *cp;
gfc_state_data s;
+ gfc_current_ns = new_st.ext.block.ns;
accept_statement (ST_SELECT_TYPE);
cp = gfc_state_stack->tail;
@@ -5188,7 +5183,7 @@ parse_executable (gfc_statement st)
break;
case ST_SELECT_TYPE:
- parse_select_type_block();
+ parse_select_type_block ();
break;
case ST_DO:
@@ -6027,12 +6022,11 @@ loop:
prog_locus = gfc_current_locus;
push_state (&s, COMP_PROGRAM, gfc_new_block);
- main_program_symbol(gfc_current_ns, gfc_new_block->name);
+ main_program_symbol (gfc_current_ns, gfc_new_block->name);
accept_statement (st);
add_global_program ();
parse_progunit (ST_NONE);
goto prog_units;
- break;
case ST_SUBROUTINE:
add_global_procedure (true);
@@ -6040,7 +6034,6 @@ loop:
accept_statement (st);
parse_progunit (ST_NONE);
goto prog_units;
- break;
case ST_FUNCTION:
add_global_procedure (false);
@@ -6048,7 +6041,6 @@ loop:
accept_statement (st);
parse_progunit (ST_NONE);
goto prog_units;
- break;
case ST_BLOCK_DATA:
push_state (&s, COMP_BLOCK_DATA, gfc_new_block);
@@ -6083,7 +6075,6 @@ loop:
main_program_symbol (gfc_current_ns, "MAIN__");
parse_progunit (st);
goto prog_units;
- break;
}
/* Handle the non-program units. */
@@ -6132,14 +6123,12 @@ prog_units:
pop_state ();
goto loop;
- done:
-
+done:
/* Do the resolution. */
resolve_all_program_units (gfc_global_ns_list);
/* Do the parse tree dump. */
- gfc_current_ns
- = flag_dump_fortran_original ? gfc_global_ns_list : NULL;
+ gfc_current_ns = flag_dump_fortran_original ? gfc_global_ns_list : NULL;
for (; gfc_current_ns; gfc_current_ns = gfc_current_ns->sibling)
if (!gfc_current_ns->proc_name