[RFC][PATCH] -d_lines
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Wed Aug 17 20:10:00 GMT 2005
Bernhard Fischer wrote:
> Several "ancient" fortran programs do exercise -- as well as most
> commercial compilers do support -- a variant of fixed-mode where 'D'
> resp. 'd' in the first column of source is either treated as comment --
> per default -- or as code -- if the compiler sees an argument akin to
> -d_lines.
>
> gfortran is, ATM, not able to deal with those, however.
Attached patch adds this support to gfortran. I thought the easiest way of
getting this simple thing in without having to wait for Bernhard's copyright
assigment, would be to take the 5 minutes and reimplement it myself.
Unfortunately, I was wrong: in order to detect the use of the -f{no-}d-line
options in free form at option parse time, I had to move the determination of
the source form into the option handling. I think this is a worthwhile
cleanup in itself, it actually removes a bit of unnecessary code which I found
when reviewing a patch by Steve a few days ago. Nevertheless, the patch
became much larger than what I originally thought.
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?
Bootstrapped and regtested on i686-pc-linux, patch and testcases attached. Ok?
- Tobi
2005-08-17 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
fortran/
* gfortran.h (gfc_option_t): Remove source field. Add
flag_d_lines field.
(gfc_new_file): Remove arguments in prototype.
* f95-lang.c (gfc_init): Use gfc_source_file instead of
gfc_option.source. Call gfc_new_file without arguments.
* invoke.texi: Document new option '-fd-lines'.
* lang.opt: Add new option '-fd-lines'. Alphabetize.
* options.c (gfc_init_options): Initialize gfc_source_file instead
of gfc_option.source. Initialize gfc_option.flag_d_lines.
(form_from_filename): Move here from scanner.c
(gfc_post_options): Set gfc_source_file. Determine source form.
* scanner.c (skip_fixed_comments): Deal with d-lines.
(form_from_filename): Moved to options.c.
(gfc_new_file): Remove arguments. Don't initialize
gfc_source_file, don't determine source form.
* trans-const.c (gfc_init_constants): Use gfc_source_file instead
of gfc_option.source.
testsuite/
* d_lines_1.f, d_lines_2.f, d_lines_3.f, d_lines_4.f: New.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: d_line.txt
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050817/3e0162f2/attachment.txt>
More information about the Fortran
mailing list