From 49e7b2d69d277a15b18fade7647f1b04e52e1777 Mon Sep 17 00:00:00 2001 From: pault Date: Thu, 24 Jan 2008 08:40:38 +0000 Subject: [PATCH] 2008-01-24 Paul Thomas PR fortran/34872 * parse.c (next_statement) : If ST_GET_FCN_CHARACTERISTICS is seen, check for a statement label and, if present, delete it and set the locus to the start of the statement. 2008-01-24 Paul Thomas PR fortran/34872 * gfortran.dg/function_charlen_3.f: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131777 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/parse.c | 11 ++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/function_charlen_3.f | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/function_charlen_3.f diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 35fd98e..0a984c3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2008-01-24 Paul Thomas + + PR fortran/34872 + * parse.c (next_statement) : If ST_GET_FCN_CHARACTERISTICS is + seen, check for a statement label and, if present, delete it + and set the locus to the start of the statement. + 2008-01-22 Paul Thomas PR fortran/34875 diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 64d8c33..20777fd 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -795,7 +795,7 @@ static gfc_statement next_statement (void) { gfc_statement st; - + locus old_locus; gfc_new_block = NULL; for (;;) @@ -824,6 +824,8 @@ next_statement (void) if (gfc_define_undef_line ()) continue; + old_locus = gfc_current_locus; + st = (gfc_current_form == FORM_FIXED) ? next_fixed () : next_free (); if (st != ST_NONE) @@ -832,6 +834,13 @@ next_statement (void) gfc_buffer_error (0); + if (st == ST_GET_FCN_CHARACTERISTICS && gfc_statement_label != NULL) + { + gfc_free_st_label (gfc_statement_label); + gfc_statement_label = NULL; + gfc_current_locus = old_locus; + } + if (st != ST_NONE) check_statement_label (st); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fe9442a..ce0ce9a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-24 Paul Thomas + + PR fortran/34872 + * gfortran.dg/function_charlen_3.f: New test. + 2008-01-23 Michael Matz PR debug/34895 diff --git a/gcc/testsuite/gfortran.dg/function_charlen_3.f b/gcc/testsuite/gfortran.dg/function_charlen_3.f new file mode 100644 index 0000000..dd4417a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/function_charlen_3.f @@ -0,0 +1,18 @@ +C { dg-do compile } +C Tests the fix for the regression PR34872, in which the re-matching of +C the function declaration made a mess if the first executable statement +C had a label. + CHARACTER FUNCTION s() + 10 CONTINUE + GOTO 10 + s = ' ' + END FUNCTION s + + CHARACTER FUNCTION t() + 10 format ("q") + write (t, 10) + END FUNCTION t + + character t + if (t() .ne. "q") call abort () + end -- 2.7.4