This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, fortran] PR34872 - [4.3 Regression] Spurious error in snapshot of 01/18/08: Statement at (1) is not a valid branch target statement for the branch statement at (2)
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 23 Jan 2008 12:06:37 +0100
- Subject: [Patch, fortran] PR34872 - [4.3 Regression] Spurious error in snapshot of 01/18/08: Statement at (1) is not a valid branch target statement for the branch statement at (2)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=H540ayUhX5Xf2wsdZV6EM5z6jGZoZfc6zvtrPjb3zqo=; b=vH12lot6FD1hA8UFYvqxXu1J5qMOLNxtvKPgXqZN+aZJVm099l+xwTSiYcELn7ng/+Ya00Gt01/aVNchlpbAMOrVlgMAsecwpT8S9KbE6aJMH/wQjHiMVeKTBSU3PMbWoH7XfD4X/kTIQ/WG5glSLs4h3RLFKnErgEMeNLOnDOE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=jzYWhvFidU1BlVBVKtNC89bJEvH33nH9KKjhRPfKbioqZmD0S3AjUWk2SVcHLVMAGSC3OJjjrxmolzdGujJ93CjyW00DxROg0OexH9IgJ1KDIgm8ZDNAst+peQbnBYYEioV5zCvbXBonQ9rGxL1SC+YSYy/b4Xb27qzejiAuZJA=
:ADDPATCH fortran:
This is a regression caused by my function characteristics patch. I
did not take account of the possibility that the first executable
statement might have a lable. The patch is self-explanatory and the
testcase based on the reporter's.
Bootstrapped and regtested on x86_ia64/FC8 - OK for trunk?
Paul
2008-01-23 Paul Thomas <pault@gcc.gnu.org>
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-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34872
* gfortran.dg/function_charlen_3.f: New test.
Index: gcc/fortran/parse.c
===================================================================
--- gcc/fortran/parse.c (revision 131710)
+++ gcc/fortran/parse.c (working copy)
@@ -795,7 +795,7 @@
next_statement (void)
{
gfc_statement st;
-
+ locus old_locus;
gfc_new_block = NULL;
for (;;)
@@ -824,6 +824,8 @@
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 @@
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);
Index: gcc/testsuite/gfortran.dg/function_charlen_3.f
===================================================================
--- gcc/testsuite/gfortran.dg/function_charlen_3.f (revision 0)
+++ gcc/testsuite/gfortran.dg/function_charlen_3.f (revision 0)
@@ -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