This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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)


: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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]