This is a patch proposal about PR fortran/18452. In short, to preprocess fortran source files, gfortran calls cc1 with its own options, which gives warnings like:

$ gfortran -fdollar-ok a.F90
cc1: warning: command line option "-fdollar-ok" is valid for F95 but not for C

A few (two exactly) options were already handled right (-ffixed-form and -ffixed-line-length-n), so I applied the method used for those to all gfortran options. Questions that need adressing are:

1. can we get that patch in during the short period when 4.1 will unfreeze before branching? it concerns the common code of GCC, and does not fix a regression strictly speaking. But that problem is very annoying to both users (which make compiling very noisy and errors difficult to spot) and developers (preventing libgfortran to be built with -Werror), and working around it while changing only gfortran code would be *ugly*.

2. what should be the behaviour of "gfortran -fdollar-ok a.f b.c"? is this supposed to be allowed, or not?

3. if the answer to point 2 is "this isn't allowed", then the testsuite framework should be somehow modified :)

4. in the case it is allowed, we then need some very clever way to get options go where they need (C-only options for b.c and Fortran-only options to a.f)

gfortran developers, C front-end maintainers, specs gurus, release managers, please speak up! :)

FX
2005-10-31  Francois-Xavier Coudert  <[EMAIL PROTECTED]>

        PR fortran/18452
        * lang.opt: Add C as language for all options that can be passed
        to the preprocessor.


2005-10-31  Francois-Xavier Coudert  <[EMAIL PROTECTED]>

        PR fortran/18452
        * gcc/c.opt: Remove -ffixed-form and -ffixed-line-length-n
        options, now completely handled in fortran/lang.opt.
        * gcc/c-opts.c: Add cases for all Fortran options declared as C
        and used only when preprocessing.

Index: gcc/fortran/lang.opt
===================================================================
--- gcc/fortran/lang.opt	(revision 106019)
+++ gcc/fortran/lang.opt	(working copy)
@@ -22,6 +22,13 @@
 
 ; Please try to keep this file in ASCII collating order.
 
+; To add a new Fortran option, you need to do the following:
+;    -- add the option in the list below, using C as well as Fortran
+;       as language if the option will be passed to the preprocessor
+;    -- get it handled by the Fortran front-end in options.c
+;    -- if you used C as language here, add it to the list of
+;       Fortran options in c_common_handle_option() in file c-opts.c
+
 Language
 Fortran
 
@@ -46,147 +53,147 @@
 Warn about implicit conversion
 
 Wimplicit-interface
-Fortran
+C Fortran
 Warn about calls with implicit interface
 
 Wline-truncation
-Fortran
+C Fortran
 Warn about truncated source lines
 
 Wnonstd-intrinsics
-Fortran
+C Fortran
 Warn about usage of non-standard intrinsics
 
 Wsurprising
-Fortran
+C Fortran
 Warn about \"suspicious\" constructs
 
 Wunderflow
-Fortran
+C Fortran
 Warn about underflow of numerical constant expressions
 
 Wunused-labels
-Fortran
+C Fortran
 Warn when a label is unused
 
 fautomatic
-Fortran
+C Fortran
 Do not treat local variables and COMMON blocks as if they were named in SAVE statements
 
 fbackslash
-Fortran
+C Fortran
 Specify that backslash in string introduces an escape character
 
 fdefault-double-8
-Fortran
+C Fortran
 Set the default double precision kind to an 8 byte wide type
 
 fdefault-integer-8
-Fortran
+C Fortran
 Set the default integer kind to an 8 byte wide type
 
 fdefault-real-8
-Fortran
+C Fortran
 Set the default real kind to an 8 byte wide type
 
 fd-lines-as-code
-Fortran RejectNegative
+C Fortran RejectNegative
 Ignore 'D' in column one in fixed form
 
 fd-lines-as-comments
-Fortran RejectNegative
+C Fortran RejectNegative
 Treat lines with 'D' in column one as comments
 
 fdollar-ok
-Fortran
+C Fortran
 Allow dollar signs in entity names
 
 fdump-parse-tree
-Fortran
+C Fortran
 Display the code tree after parsing
 
 ff2c
-Fortran
+C Fortran
 Use f2c calling convention
 
 ffixed-form
-Fortran
+C Fortran
 Assume that the source file is fixed form
 
 ffree-form
-Fortran
+C Fortran
 Assume that the source file is free form
 
 funderscoring
-Fortran
+C Fortran
 Append underscores to externally visible names
 
 fcray-pointer
-Fortran
+C Fortran
 Use the Cray Pointer extension
 
 fsecond-underscore
-Fortran
+C Fortran
 Append a second underscore if the name already contains an underscore
 
 fimplicit-none
-Fortran
+C Fortran
 Specify that no implicit typing is allowed, unless overridden by explicit IMPLICIT statements
 
 ffixed-line-length-none
-Fortran RejectNegative
+C Fortran RejectNegative
 Allow arbitrary character line width in fixed mode
 
 ffixed-line-length-
-Fortran RejectNegative Joined UInteger
+C Fortran RejectNegative Joined UInteger
 -ffixed-line-length-<n>		Use n as character line width in fixed mode
 
 fmax-identifier-length=
-Fortran RejectNegative Joined UInteger
+C Fortran RejectNegative Joined UInteger
 -fmax-identifier-length=<n>	Maximum identifier length
 
 fmax-stack-var-size=
-Fortran RejectNegative Joined UInteger
+C Fortran RejectNegative Joined UInteger
 -fmax-stack-var-size=<n>	Size in bytes of the largest array that will be put on the stack
 
 fmodule-private
-Fortran
+C Fortran
 Set default accessibility of module entities to PRIVATE
 
 fno-backend
-Fortran RejectNegative
+C Fortran RejectNegative
 Don't generate code, just do syntax and semantics checking
 
 fpack-derived
-Fortran
+C Fortran
 Try to layout derived types as compact as possible
 
 frepack-arrays
-Fortran
+C Fortran
 Copy array sections into a contiguous block on procedure entry
 
 qkind=
-Fortran RejectNegative Joined UInteger
+C Fortran RejectNegative Joined UInteger
 -qkind=<n>	Set the kind for a real with the 'q' exponent to 'n'
 
 ffpe-trap=
-Fortran RejectNegative JoinedOrMissing
+C Fortran RejectNegative JoinedOrMissing
 -ffpe-trap=[..]	Stop on following floating point exceptions
 
 std=f95
-Fortran
+C Fortran
 Conform to the ISO Fortran 95 standard
 
 std=f2003
-Fortran
+C Fortran
 Conform to the ISO Fortran 2003 standard
 
 std=gnu
-Fortran
+C Fortran
 Conform nothing in particular
 
 std=legacy
-Fortran
+C Fortran
 Accept extensions to support legacy code
 
 ; This comment is to ensure we retain the blank line above.
Index: gcc/c.opt
===================================================================
--- gcc/c.opt	(revision 106019)
+++ gcc/c.opt	(working copy)
@@ -507,12 +507,6 @@
 fexternal-templates
 C++ ObjC++
 
-ffixed-form
-C ObjC
-
-ffixed-line-length-
-C ObjC Joined
-
 ffor-scope
 C++ ObjC++
 Scope of for-init-statement variables is local to the loop
Index: gcc/c-opts.c
===================================================================
--- gcc/c-opts.c	(revision 106019)
+++ gcc/c-opts.c	(working copy)
@@ -651,9 +651,45 @@
       cpp_opts->extended_identifiers = value;
       break;
 
+    case OPT_Wimplicit_interface:
+    case OPT_Wline_truncation:
+    case OPT_Wnonstd_intrinsics:
+    case OPT_Wsurprising:
+    case OPT_Wunderflow:
+    case OPT_Wunused_labels:
+    case OPT_fautomatic:
+    case OPT_fbackslash:
+    case OPT_fdefault_double_8:
+    case OPT_fdefault_integer_8:
+    case OPT_fdefault_real_8:
+    case OPT_fd_lines_as_code:
+    case OPT_fd_lines_as_comments:
+    case OPT_fdollar_ok:
+    case OPT_fdump_parse_tree:
+    case OPT_ff2c:
     case OPT_ffixed_form:
+    case OPT_ffree_form:
+    case OPT_funderscoring:
+    case OPT_fcray_pointer:
+    case OPT_fsecond_underscore:
+    case OPT_fimplicit_none:
+    case OPT_ffixed_line_length_none:
     case OPT_ffixed_line_length_:
-      /* Fortran front end options ignored when preprocessing only.  */
+    case OPT_fmax_identifier_length_:
+    case OPT_fmax_stack_var_size_:
+    case OPT_fmodule_private:
+    case OPT_fno_backend:
+    case OPT_fpack_derived:
+    case OPT_frepack_arrays:
+    case OPT_qkind_:
+    case OPT_ffpe_trap_:
+    case OPT_std_f95:
+    case OPT_std_f2003:
+    case OPT_std_gnu:
+    case OPT_std_legacy:
+      /* Fortran front end options ignored when preprocessing only.
+         This list is to be kept in sync with the list of options in
+	 fortran/lang.opt with C as language.  */
       if (!flag_preprocess_only)
         result = 0;
       break;

Reply via email to