[RFC][PATCH] -d_lines

Bernhard Fischer rep.nop@aon.at
Thu Aug 18 01:51:00 GMT 2005


On Wed, Aug 17, 2005 at 09:54:58PM +0200, Tobias Schlüter wrote:

>There are two questions:
>1. we had two places where we store the source file: gfc_options.source and
>gfc_source_file.  I decided to keep the latter and remove the former, but I
>can also understand if we would rather want to keep the former (this would
>follow the spirit of keeping everything given on the command line into
>gfc_option)?  In the same spirit, should we also move gfc_current_form into
>gfc_option?
>2. I've decided to create three possibilities:
>   - -fd-lines given: treat 'd' in column 1 as equivalent to a single blank
>   - -fno-d-lines given: treat 'D' in column 1 as equivalent to a 'C'
>     (=comment)
>   - neither option given: syntax error (behavior following the standard)
>Does everybody agree that this is the right way to deal with this?

Personally, i'd prefer to have -fno-d-lines as default (eventually warn
about it in -pedantic).

>Index: fortran/invoke.texi
>===================================================================
>RCS file: /cvs/gcc/gcc/gcc/fortran/invoke.texi,v
>retrieving revision 1.19
>diff -u -p -r1.19 invoke.texi
>--- fortran/invoke.texi	6 Aug 2005 12:56:18 -0000	1.19
>+++ fortran/invoke.texi	17 Aug 2005 18:20:20 -0000
>@@ -183,6 +183,13 @@ Specify the layout used by the source fi
> was introduced in Fortran 90.  Fixed form was traditionally used in
> older Fortran programs.
> 
>+@cindex option, -fd-lines
>+@cindex -fd-lines, option
>+@item -fd-lines
>+Enables debug lines in fixed form sources.  Debug lines are lines with
>+a @samp{D} in column 1.  If this option is not given or if
>+@option{-fno-d-lines} is given, they are treated as comments.

According to 2c above, the description for 'option not given' is not
correct. As earlier noted by someone else, please add the lowercase d.

>+
> @cindex option, -fdefault-double-8
> @cindex -fdefault-double-8, option
> @item -fdefault-double-8
>Index: fortran/lang.opt
>===================================================================
>RCS file: /cvs/gcc/gcc/gcc/fortran/lang.opt,v
>retrieving revision 1.16
>diff -u -p -r1.16 lang.opt
>--- fortran/lang.opt	2 Jul 2005 13:19:54 -0000	1.16
>+++ fortran/lang.opt	17 Aug 2005 18:20:20 -0000
>@@ -81,13 +85,13 @@ fdefault-real-8
> F95
> Set the default real kind to an 8 byte wide type
> 
>-fdollar-ok
>+fd-lines
> F95
>-Allow dollar signs in entity names
>+Don't interpret lines with 'D' in column zero as comments in fixed form

Do columns in text files start with 0 or 1, from a user perspective?

>Index: fortran/options.c
>===================================================================
>RCS file: /cvs/gcc/gcc/gcc/fortran/options.c,v
>retrieving revision 1.22
>diff -u -p -r1.22 options.c
>--- fortran/options.c	25 Jun 2005 00:40:35 -0000	1.22
>+++ fortran/options.c	17 Aug 2005 18:20:20 -0000
>@@ -102,7 +174,28 @@ gfc_post_options (const char **pfilename
>       filename = "";
>     }
> 
>-  gfc_option.source = filename;
>+  gfc_source_file = xstrdup (filename);
>+
>+  /* Decide which form the file will be read in as.  */
>+
>+  if (gfc_option.source_form != FORM_UNKNOWN)
>+    gfc_current_form = gfc_option.source_form;
>+  else
>+    {
>+      gfc_current_form = form_from_filename (filename);
>+
>+      if (gfc_current_form == FORM_UNKNOWN)
>+	{
>+	  gfc_current_form = FORM_FREE;
>+	  gfc_warning_now ("Reading file '%s' as free form.", 
>+			   (filename[0] == '\0') ? "<stdin>" : filename); 
>+	}
>+    }
>+
>+  /* If the user specified -fd-lines or fno-d-lines verify that we're

s/fno/-fno/

>+     in fixed form.  */
>+  if (gfc_option.flag_d_lines != -1 && gfc_current_form == FORM_FREE)
>+    gfc_warning_now ("'-f-d-lines' has no effect in free form.");
> 
>   flag_inline_trees = 1;
> 
>Index: fortran/scanner.c
>===================================================================
>RCS file: /cvs/gcc/gcc/gcc/fortran/scanner.c,v
>retrieving revision 1.23
>diff -u -p -r1.23 scanner.c
>--- fortran/scanner.c	9 Aug 2005 08:08:28 -0000	1.23
>+++ fortran/scanner.c	17 Aug 2005 18:20:20 -0000
>@@ -386,6 +388,27 @@ skip_fixed_comments (void)
> 	}
> 
>       col = 1;
>+
>+      if (c == 'd' || c == 'D')
>+	{
>+	  if (gfc_option.flag_d_lines == 0)
>+	    {
>+	      skip_comment_line ();
>+	      continue;
>+	    }
>+	  else if (gfc_option.flag_d_lines == 1)
>+	    {
>+	      *start.nextc = ' ';
>+	      col = 2;
>+	    }
>+	  else
>+	    {
>+	      /* Let the syntax error be caught elsewhere.  */
>+	      gfc_current_locus = start;
>+	      col = 1;
Looks like col should already be 1 here.
I'll try your patch tomorrow to see why you need this whole else block
at all.

>+	    }
>+	}
>+
>       do
> 	{
> 	  c = next_char ();

cheers,
Bernhard



More information about the Fortran mailing list