public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/53077] suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor
Date: Mon, 23 Apr 2012 08:27:00 -0000	[thread overview]
Message-ID: <bug-53077-4-UgWxxHfncp@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53077-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53077

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-23 08:27:05 UTC ---
> Hmm... apparently the PGI compiler uses the same rule for enabling
> preprocessor with .f and .F extensions.

I think most compilers follow that pattern, which can be overridden by "-cpp"
and "-no-cpp", respectively.


> Then, if there's some important reason behind it (?)

Well, the C preprocessor is not part of the Fortran standard, thus, a compiler
can expect that no C preprocessing has to be done. (Though, most compilers do
support CPP preprocessing; there are some caveats with regards to newer CPP
features: The preprocessor has then to be aware of Fortran. Thus, many
compilers do not support the CPP of newer C standards.)

Side note: The Fortran 95 standard actually defines in Part 3 "Conditional
Compilation" (ISO/IEC 1539-3:1998), however, this Fortran-specific way was
never widely used and it is not implemented in any compiler (to my knowledge).
However, there exists a preprocessor "coco" (written in Fortran).


> perhaps at least the warning message could be improved by indicating that the
> preprocessor is off.

I concur.


Untested patch.

Remark: At some point, gfortran needs to follow GCC with regards to
-f(no-)diagnostics-show-caret. I now keep the "<file>:<line>:" with -cpp but
the caret diagnostic without.

--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -1792,4 +1792,9 @@ preprocessor_line (gfc_char_t *c)
  bad_cpp_line:
-  gfc_warning_now ("%s:%d: Illegal preprocessor directive",
-                  current_file->filename, current_file->line);
+  if (gfc_cpp_enabled ())
+    gfc_warning_now ("%s:%d: Illegal preprocessor directive",
+                    current_file->filename, current_file->line);
+  else
+    gfc_warning_now ("Ignoring preprocessor directive at %C. Used -cpp to ",
+                    "enable the C preprocessor");
+
   current_file->line++;(In reply to comment #2)


  parent reply	other threads:[~2012-04-23  8:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-22 20:34 [Bug fortran/53077] New: " slayoo at staszic dot waw.pl
2012-04-22 20:36 ` [Bug fortran/53077] " slayoo at staszic dot waw.pl
2012-04-22 21:36 ` slayoo at staszic dot waw.pl
2012-04-23  1:17 ` pinskia at gcc dot gnu.org
2012-04-23  8:27 ` burnus at gcc dot gnu.org [this message]
2012-04-23 11:13 ` slayoo at staszic dot waw.pl
2014-02-08 14:54 ` [Bug fortran/53077] replace "Illegal preprocessor directive" message with "Ignoring preprocessor directive at %C. Use -cpp to enable the C preprocessor" (a patch by Tobias included) dominiq at lps dot ens.fr
2020-04-12 16:33 ` dominiq at lps dot ens.fr

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=bug-53077-4-UgWxxHfncp@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.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).