public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor
@ 2012-04-22 20:34 slayoo at staszic dot waw.pl
  2012-04-22 20:36 ` [Bug fortran/53077] " slayoo at staszic dot waw.pl
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: slayoo at staszic dot waw.pl @ 2012-04-22 20:34 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53077
           Summary: suggestion to add the .f extension to the list of file
                    extensions that trigger enabling of the preprocessor
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: slayoo@staszic.waw.pl


Hello,


$ cat test.f
#define print(x) print*, x
program test
  print('aqq')
end
$ gfortran -ffree-form test.f
Warning: test.f:1: Illegal preprocessor directive
test.f:3.8:

  print('aqq')
        1
Error: Missing leading left parenthesis in format string at (1)
$ mv test.f test.F
$ gfortran-mp-4.6 -ffree-form test.F && echo OK
OK



This behavior is consistent with the docs but it's quite misleading, especially
as the warning message might be understood as if there was something wrong
within the macro definition, and not with the fact that the macro is there at
all.

Why not turning on the preprocessor with .f extensions as well? 
(currently only the .F extension turns it on by default)

HTH,
Sylwester


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/53077] suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor
  2012-04-22 20:34 [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor slayoo at staszic dot waw.pl
@ 2012-04-22 20:36 ` slayoo at staszic dot waw.pl
  2012-04-22 21:36 ` slayoo at staszic dot waw.pl
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: slayoo at staszic dot waw.pl @ 2012-04-22 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Sylwester Arabas <slayoo at staszic dot waw.pl> 2012-04-22 20:35:49 UTC ---
The gfortran-mp-4.6 vs. gfortran difference in the code above is not relevant
to the issue.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/53077] suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor
  2012-04-22 20:34 [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor 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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: slayoo at staszic dot waw.pl @ 2012-04-22 21:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Sylwester Arabas <slayoo at staszic dot waw.pl> 2012-04-22 21:36:33 UTC ---
Hmm... apparently the PGI compiler uses the same rule for enabling preprocessor
with .f and .F extensions. Then, if there's some important reason behind it (?)
perhaps at least the warning message could be improved by indicating that the
preprocessor is off.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/53077] suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor
  2012-04-22 20:34 [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor 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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-04-23  1:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-04-23 01:17:16 UTC ---
Why can't you just pass the -cpp option to gfortran if you want to enable the
preprocessor?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/53077] suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor
  2012-04-22 20:34 [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor slayoo at staszic dot waw.pl
                   ` (2 preceding siblings ...)
  2012-04-23  1:17 ` pinskia at gcc dot gnu.org
@ 2012-04-23  8:27 ` burnus at gcc dot gnu.org
  2012-04-23 11:13 ` slayoo at staszic dot waw.pl
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-23  8:27 UTC (permalink / raw)
  To: gcc-bugs

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)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/53077] suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor
  2012-04-22 20:34 [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor slayoo at staszic dot waw.pl
                   ` (3 preceding siblings ...)
  2012-04-23  8:27 ` burnus at gcc dot gnu.org
@ 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
  6 siblings, 0 replies; 8+ messages in thread
From: slayoo at staszic dot waw.pl @ 2012-04-23 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Sylwester Arabas <slayoo at staszic dot waw.pl> 2012-04-23 11:13:21 UTC ---
Thanks for quick replies.

> Why can't you just pass the -cpp option to gfortran
> if you want to enable the preprocessor?

Of course you can, but first you need to know that the
"Illegal preprocessor directive" warning actually means 
that the preprocessor is off :)

> Untested patch.

I guess "Used -cpp to" should read "Use -cpp to".

Thanks,
Sylwester


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [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)
  2012-04-22 20:34 [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor slayoo at staszic dot waw.pl
                   ` (4 preceding siblings ...)
  2012-04-23 11:13 ` slayoo at staszic dot waw.pl
@ 2014-02-08 14:54 ` dominiq at lps dot ens.fr
  2020-04-12 16:33 ` dominiq at lps dot ens.fr
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-02-08 14:54 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-02-08
     Ever confirmed|0                           |1

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Is there any objection if I do the testing and packaging for the patch in
comment 4?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [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)
  2012-04-22 20:34 [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor slayoo at staszic dot waw.pl
                   ` (5 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-04-12 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|dominiq at lps dot ens.fr          |unassigned at gcc dot gnu.org

--- Comment #9 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Unassigning myself.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-12 16:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-22 20:34 [Bug fortran/53077] New: suggestion to add the .f extension to the list of file extensions that trigger enabling of the preprocessor 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
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

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).