On Wednesday 17 August 2011 00:05:57 Tobias Burnus wrote: > > I can propose the following ad-hoc fix for the two latter cases. > > > > The patch passes gfortran.dg/*goto* and gfortran.dg/*label*, and I'm > > doing a full regression test. Is that OK? > > That's OK with test cases (original issue plus the two newly fixed > ones). Nit: You have a missing tab at: [...]
I committed the first patch as revision 177882 and the second one with testcases and the space nit fixed as revision 177885 (diff attached). > > > About your two former cases, the first one looks especially tricky. For > > the second one, it may be valid, but a warning would be nice IMO as one > > of the labels is masked by the other. Both cases need more investigation > > anyway. > > I think those could be deferred. - If you don't work on them, one should > fill a PR to make sure they do not get forgotten. > You have already added them as comments to PR 50071, but I will make separate PRs for them. Mikael
Index: testsuite/gfortran.dg/end_block_label_1.f90 =================================================================== --- testsuite/gfortran.dg/end_block_label_1.f90 (révision 0) +++ testsuite/gfortran.dg/end_block_label_1.f90 (révision 177885) @@ -0,0 +1,14 @@ +! { dg-do compile } +! +! PR fortran/50071 +! A label in an END BLOCK statement was ignored; as a result, a GOTO +! to such a label was rejected. +! +! Contributed by Tobias Burnus <bur...@net-b.de> + + block + goto 1 + print *, 'Hello' +1 end block +end + Index: testsuite/gfortran.dg/end_associate_label_1.f90 =================================================================== --- testsuite/gfortran.dg/end_associate_label_1.f90 (révision 0) +++ testsuite/gfortran.dg/end_associate_label_1.f90 (révision 177885) @@ -0,0 +1,14 @@ +! { dg-do compile } +! +! PR fortran/50071 +! A label in an END ASSOCIATE statement was ignored; as a result, a GOTO +! to such a label was rejected. +! +! Contributed by Tobias Burnus <bur...@net-b.de> + + integer :: i + associate (j => i) + goto 1 + print *, 'Hello' +1 end associate +end Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (révision 177884) +++ testsuite/ChangeLog (révision 177885) @@ -1,3 +1,9 @@ +2011-08-19 Mikael Morin <mikael.mo...@sfr.fr> + + PR fortran/50071 + * gfortran.dg/end_block_label_1.f90: New test. + * gfortran.dg/end_associate_label_1.f90: New test. + 2011-08-18 Joseph Myers <jos...@codesourcery.com> * gcc.dg/c1x-pointer-float-1.c: New test. Index: fortran/gfortran.h =================================================================== --- fortran/gfortran.h (révision 177884) +++ fortran/gfortran.h (révision 177885) @@ -2048,8 +2048,8 @@ /* Executable statements that fill gfc_code structures. */ typedef enum { - EXEC_NOP = 1, EXEC_END_BLOCK, EXEC_ASSIGN, EXEC_LABEL_ASSIGN, - EXEC_POINTER_ASSIGN, EXEC_CRITICAL, EXEC_ERROR_STOP, + EXEC_NOP = 1, EXEC_END_NESTED_BLOCK, EXEC_END_BLOCK, EXEC_ASSIGN, + EXEC_LABEL_ASSIGN, EXEC_POINTER_ASSIGN, EXEC_CRITICAL, EXEC_ERROR_STOP, EXEC_GOTO, EXEC_CALL, EXEC_COMPCALL, EXEC_ASSIGN_CALL, EXEC_RETURN, EXEC_ENTRY, EXEC_PAUSE, EXEC_STOP, EXEC_CONTINUE, EXEC_INIT_ASSIGN, EXEC_IF, EXEC_ARITHMETIC_IF, EXEC_DO, EXEC_DO_WHILE, EXEC_SELECT, EXEC_BLOCK, Index: fortran/ChangeLog =================================================================== --- fortran/ChangeLog (révision 177884) +++ fortran/ChangeLog (révision 177885) @@ -1,3 +1,18 @@ +2011-08-19 Mikael Morin <mikael.mo...@sfr.fr> + + PR fortran/50071 + * gfortran.h (gfc_exec_op): New constant EXEC_END_NESTED_BLOCK. + * parse.c (check_statement_label): Accept ST_END_BLOCK and + ST_END_ASSOCIATE as valid branch target. + (accept_statement): Change EXEC_END_BLOCK to EXEC_END_NESTED_BLOCK. + Add EXEC_END_BLOCK code in the ST_END_BLOCK and ST_END_ASSOCIATE cases. + * resolve.c (find_reachable_labels): Change EXEC_END_BLOCK to + EXEC_END_NESTED_BLOCK. + (resolve_branch): Ditto. + (resolve_code): Add EXEC_END_NESTED_BLOCK case. + * st.c (gfc_free_statement): Ditto. + * trans.c (trans_code): Ditto. + 2011-08-18 Mikael Morin <mikael.mo...@sfr.fr> PR fortran/50071 Index: fortran/trans.c =================================================================== --- fortran/trans.c (révision 177884) +++ fortran/trans.c (révision 177885) @@ -1188,6 +1188,7 @@ { case EXEC_NOP: case EXEC_END_BLOCK: + case EXEC_END_NESTED_BLOCK: case EXEC_END_PROCEDURE: res = NULL_TREE; break; Index: fortran/resolve.c =================================================================== --- fortran/resolve.c (révision 177884) +++ fortran/resolve.c (révision 177885) @@ -8202,7 +8202,7 @@ up through the code_stack. */ for (c = block; c; c = c->next) { - if (c->here && c->op != EXEC_END_BLOCK) + if (c->here && c->op != EXEC_END_NESTED_BLOCK) bitmap_set_bit (cs_base->reachable_labels, c->here->value); } @@ -8381,7 +8381,7 @@ if (stack) { - gcc_assert (stack->current->next->op == EXEC_END_BLOCK); + gcc_assert (stack->current->next->op == EXEC_END_NESTED_BLOCK); return; } @@ -9117,6 +9117,7 @@ { case EXEC_NOP: case EXEC_END_BLOCK: + case EXEC_END_NESTED_BLOCK: case EXEC_CYCLE: case EXEC_PAUSE: case EXEC_STOP: Index: fortran/st.c =================================================================== --- fortran/st.c (révision 177884) +++ fortran/st.c (révision 177885) @@ -89,6 +89,7 @@ { case EXEC_NOP: case EXEC_END_BLOCK: + case EXEC_END_NESTED_BLOCK: case EXEC_ASSIGN: case EXEC_INIT_ASSIGN: case EXEC_GOTO: Index: fortran/parse.c =================================================================== --- fortran/parse.c (révision 177884) +++ fortran/parse.c (révision 177885) @@ -1115,6 +1115,8 @@ case ST_ENDIF: case ST_END_SELECT: case ST_END_CRITICAL: + case ST_END_BLOCK: + case ST_END_ASSOCIATE: case_executable: case_exec_markers: type = ST_LABEL_TARGET; @@ -1627,6 +1629,18 @@ case ST_END_CRITICAL: if (gfc_statement_label != NULL) { + new_st.op = EXEC_END_NESTED_BLOCK; + add_statement (); + } + break; + + /* In the case of BLOCK and ASSOCIATE blocks, there cannot be more than + one parallel block. Thus, we add the special code to the nested block + itself, instead of the parent one. */ + case ST_END_BLOCK: + case ST_END_ASSOCIATE: + if (gfc_statement_label != NULL) + { new_st.op = EXEC_END_BLOCK; add_statement (); }