public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Rimvydas Jasinskas <rimvydasjas@gmail.com>
To: Rimvydas Jasinskas via Fortran <fortran@gcc.gnu.org>,
	gcc-patches@gnu.org
Subject: Fortran: Use non conflicting file extensions for intermediates [PR81615]
Date: Wed, 20 Dec 2023 06:32:37 +0200	[thread overview]
Message-ID: <CAFmAMQ214FmTReOkMaxCuxEiCKO7gWGAittA=H08K3x8ewTJbw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

Dear all,

In the spirit of c/c++ using the .i/.ii extensions for intermediates,
use the .fi/.fii intermediate extensions for gfortran fixed/free form
sources when -save-temps is invoked to avoid various issues.

The documentation part will be submitted separately, because it
involves adding a "Developer options" mini-section (as suggested by
Harald) and moving the -fdump-* options from "Options for debugging
your program or GNU Fortran" section.

Regards,
Rimvydas

[-- Attachment #2: 0001-Fortran-Use-non-conflicting-file-extensions-for-inte.patch --]
[-- Type: text/x-patch, Size: 3610 bytes --]

From d313ccb110c5418260b667c5f289a249247de059 Mon Sep 17 00:00:00 2001
From: Rimvydas Jasinskas <rimvydas.jas@gmail.com>
Date: Wed, 20 Dec 2023 03:39:33 +0000
Subject: Fortran: Use non conflicting file extensions for intermediates
 [PR81615]

gcc/ChangeLog:

	* doc/invoke.texi: Document the new file extensions

gcc/fortran/ChangeLog:

	PR fortran/81615
	* lang-specs.h (F951_CPP_OPTIONS): Do not hardcode ".f90" extension
	(F951_CPP_EXTENSION): Use .fi/.fii for fixed/free form sources
	* options.cc (form_from_filename): Handle the new extensions

Signed-off-by: Rimvydas Jasinskas <rimvydas.jas@gmail.com>
---
 gcc/doc/invoke.texi      |  2 ++
 gcc/fortran/lang-specs.h | 10 +++++++++-
 gcc/fortran/options.cc   |  6 ++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 940adbce1bd..22313a86d9a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1591,6 +1591,7 @@ C++ header file to be turned into a precompiled header or Ada spec.
 @item @var{file}.f
 @itemx @var{file}.for
 @itemx @var{file}.ftn
+@itemx @var{file}.fi
 Fixed form Fortran source code that should not be preprocessed.
 
 @item @var{file}.F
@@ -1605,6 +1606,7 @@ preprocessor).
 @itemx @var{file}.f95
 @itemx @var{file}.f03
 @itemx @var{file}.f08
+@itemx @var{file}.fii
 Free form Fortran source code that should not be preprocessed.
 
 @item @var{file}.F90
diff --git a/gcc/fortran/lang-specs.h b/gcc/fortran/lang-specs.h
index 7b298457613..5b1ea00cf0d 100644
--- a/gcc/fortran/lang-specs.h
+++ b/gcc/fortran/lang-specs.h
@@ -29,7 +29,8 @@
 /* Options that f951 should know about, even if not preprocessing.  */
 #define CPP_FORWARD_OPTIONS "%{i*} %{I*} %{M*}"
 
-#define F951_CPP_OPTIONS    "%{!nocpp: -cpp=%g.f90 %{E} %(cpp_unique_options) \
+#define F951_CPP_OPTIONS    "%{!nocpp: -cpp=%g" F951_CPP_EXTENSION \
+			     " %{E} %(cpp_unique_options) \
 			     %{E|M|MM:%(cpp_debug_options) " CPP_ONLY_OPTIONS \
 			     " -fsyntax-only};: " CPP_FORWARD_OPTIONS "}"
 
@@ -44,6 +45,7 @@
 #define F951_SOURCE_FORM    "%{!ffree-form:-ffixed-form}"
 
 
+#define F951_CPP_EXTENSION  ".fi"
 {".F",   "@f77-cpp-input", 0, 0, 0},
 {".FOR", "@f77-cpp-input", 0, 0, 0},
 {".FTN", "@f77-cpp-input", 0, 0, 0},
@@ -55,11 +57,15 @@
 {".f",   "@f77", 0, 0, 0},
 {".for", "@f77", 0, 0, 0},
 {".ftn", "@f77", 0, 0, 0},
+{".fi",  "@f77", 0, 0, 0},
 {"@f77",
     "f951 %i " F951_SOURCE_FORM " \
           %{E:%{!cpp:%egfortran does not support -E without -cpp}} \
           %{cpp:" F951_CPP_OPTIONS ";: " CPP_FORWARD_OPTIONS  "} \
 	  %{!E:" F951_OPTIONS "}", 0, 0, 0},
+
+#undef F951_CPP_EXTENSION
+#define F951_CPP_EXTENSION  ".fii"
 {".F90", "@f95-cpp-input", 0, 0, 0},
 {".F95", "@f95-cpp-input", 0, 0, 0},
 {".F03", "@f95-cpp-input", 0, 0, 0},
@@ -70,6 +76,7 @@
 {".f95", "@f95", 0, 0, 0},
 {".f03", "@f95", 0, 0, 0},
 {".f08", "@f95", 0, 0, 0},
+{".fii", "@f95", 0, 0, 0},
 {"@f95",
     "f951 %i %{E:%{!cpp:%egfortran does not support -E without -cpp}}\
 	  %{cpp:" F951_CPP_OPTIONS ";:  " CPP_FORWARD_OPTIONS  "} \
@@ -79,5 +86,6 @@
 #undef CPP_ONLY_OPTIONS
 #undef CPP_FORWARD_OPTIONS
 #undef F951_SOURCE_FORM
+#undef F951_CPP_EXTENSION
 #undef F951_CPP_OPTIONS
 #undef F951_OPTIONS
diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc
index 02a29f83b58..53a6e8553bb 100644
--- a/gcc/fortran/options.cc
+++ b/gcc/fortran/options.cc
@@ -199,6 +199,12 @@ form_from_filename (const char *filename)
     ".f08", FORM_FREE}
     ,
     {
+    ".fii", FORM_FREE}
+    ,
+    {
+    ".fi", FORM_FIXED}
+    ,
+    {
     ".f", FORM_FIXED}
     ,
     {
-- 
2.43.0


             reply	other threads:[~2023-12-20  4:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20  4:32 Rimvydas Jasinskas [this message]
2023-12-20 19:29 ` Harald Anlauf
2023-12-20 19:29   ` Harald Anlauf
2023-12-24  1:33   ` Rimvydas Jasinskas
2023-12-27 20:34     ` Harald Anlauf
2023-12-27 20:34       ` Harald Anlauf
2023-12-28  7:09       ` Rimvydas Jasinskas
2023-12-28 20:31         ` Harald Anlauf
2023-12-28 20:31           ` Harald Anlauf
2023-12-30 11:01     ` Thomas Koenig
2023-12-30 11:08       ` Thomas Koenig
2024-01-01 21:25         ` Harald Anlauf
2024-01-01 21:25           ` Harald Anlauf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFmAMQ214FmTReOkMaxCuxEiCKO7gWGAittA=H08K3x8ewTJbw@mail.gmail.com' \
    --to=rimvydasjas@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).