public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran
@ 2020-03-19 20:01 markwayne1969 at gmail dot com
  2020-03-19 20:07 ` [Bug fortran/94228] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: markwayne1969 at gmail dot com @ 2020-03-19 20:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94228
           Summary: Preprocessor inconsistency for macros when invoked
                    from gfortran
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: markwayne1969 at gmail dot com
  Target Milestone: ---

This report details differing behavior for preprocessor directives containing
variadic macros when processed directly by cpp

    $ cpp-9 --version
    cpp-9 (Homebrew GCC 9.2.0_3) 9.2.0
    Copyright (C) 2019 Free Software Foundation, Inc.

and when invoked from the gfortran compiler

    $ gfortran-9 --version
    GNU Fortran (Homebrew GCC 9.2.0_3) 9.2.0
    Copyright (C) 2019 Free Software Foundation, Inc.

An MWE is included.

1) The source ('test-function-macro.f90'):

    ! filename: test-function-macro.f90
    ! v0: Thu Mar 19 11:06:40 2020

    program test_function_macro
       implicit none

    #define F(...) print *, 0,__VA_ARGS__
       F('1','2','3')

    end program test_function_macro

2) cpp direct processing:

    $ cpp-9 test-function-macro.f90
    # 1 "test-function-macro.f90"
    # 1 "<built-in>"
    # 1 "<command-line>"
    # 1 "test-function-macro.f90"
    ! filename: test-function-macro.f90
    ! v0: Thu Mar 19 11:06:40 2020

    program test_function_macro
       implicit none


       print *, 0,'1','2','3'

    end program test_function_macro

3) gfortran invocation:

    $ gfortran-9 -cpp test-function-macro.f90
    test-function-macro.f90:7:0:

        7 | #define F(...) print *, 0,__VA_ARGS__
          |
    Error: syntax error in macro parameter list


4) Comments

  i) the behavior in item 2) is the desired behavior
 ii) the behavior in item 3) is undesired
iii) The system is runs mac OS; the behavior is identical whether the above cpp
is used or the system cpp is used:

    $ cpp --version
    Apple LLVM version 10.0.1 (clang-1001.0.46.4)
    Target: x86_64-apple-darwin18.7.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin

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

* [Bug fortran/94228] Preprocessor inconsistency for macros when invoked from gfortran
  2020-03-19 20:01 [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran markwayne1969 at gmail dot com
@ 2020-03-19 20:07 ` pinskia at gcc dot gnu.org
  2020-03-19 21:01 ` markwayne1969 at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-03-19 20:07 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
gfortran defaults to -traditional-cpp preprocessor mode.

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

* [Bug fortran/94228] Preprocessor inconsistency for macros when invoked from gfortran
  2020-03-19 20:01 [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran markwayne1969 at gmail dot com
  2020-03-19 20:07 ` [Bug fortran/94228] " pinskia at gcc dot gnu.org
@ 2020-03-19 21:01 ` markwayne1969 at gmail dot com
  2020-03-19 21:48 ` kargl at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: markwayne1969 at gmail dot com @ 2020-03-19 21:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Mark Paris <markwayne1969 at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> gfortran defaults to -traditional-cpp preprocessor mode.

Thank you for your reply. If I may, I'd like to pose a question that I cannot
find the answer to from online sources:

Is it possible to run the preprocessor in the ISO mode, not the traditional
mode, when invoked by gfortran?

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

* [Bug fortran/94228] Preprocessor inconsistency for macros when invoked from gfortran
  2020-03-19 20:01 [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran markwayne1969 at gmail dot com
  2020-03-19 20:07 ` [Bug fortran/94228] " pinskia at gcc dot gnu.org
  2020-03-19 21:01 ` markwayne1969 at gmail dot com
@ 2020-03-19 21:48 ` kargl at gcc dot gnu.org
  2020-03-19 22:24 ` markwayne1969 at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-03-19 21:48 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #3 from kargl at gcc dot gnu.org ---
(In reply to Mark Paris from comment #2)
> (In reply to Andrew Pinski from comment #1)
> > gfortran defaults to -traditional-cpp preprocessor mode.
> 
> Thank you for your reply. If I may, I'd like to pose a question that I
> cannot find the answer to from online sources:
> 
> Is it possible to run the preprocessor in the ISO mode, not the traditional
> mode, when invoked by gfortran?

No.  Newer C, as opposed to older C, uses // for a comment.
Fortran uses // as the concatenation operator.  Run this
through a cpp pre-processor.

character(len=80) :: name = 'john ' // 'Doe'
print *, name
end

 ~/work/bin/cpp a.F
# 1 "a.F"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "a.F"
character(len=80) :: name = 'john '
print *, name
end

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

* [Bug fortran/94228] Preprocessor inconsistency for macros when invoked from gfortran
  2020-03-19 20:01 [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran markwayne1969 at gmail dot com
                   ` (2 preceding siblings ...)
  2020-03-19 21:48 ` kargl at gcc dot gnu.org
@ 2020-03-19 22:24 ` markwayne1969 at gmail dot com
  2020-03-20  1:12 ` sgk at troutmask dot apl.washington.edu
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: markwayne1969 at gmail dot com @ 2020-03-19 22:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Mark Paris <markwayne1969 at gmail dot com> ---
(In reply to kargl from comment #3)
> No.  Newer C, as opposed to older C, uses // for a comment.
> Fortran uses // as the concatenation operator.  Run this
> through a cpp pre-processor.
> 
> character(len=80) :: name = 'john ' // 'Doe'
> print *, name
> end
> 
>  ~/work/bin/cpp a.F
> # 1 "a.F"
> # 1 "<built-in>"
> # 1 "<command-line>"
> # 1 "a.F"
> character(len=80) :: name = 'john '
> print *, name
> end

Thank you for your kind reply. I understand that this is an issue of disparate
use of the same operator, '//' in C and Fortran.

Is it possible to have cpp recognize the different uses of // by, say, the file
name extension of the source being processed?

Links to information about gcc development for this specific possible feature
would be appreciated.

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

* [Bug fortran/94228] Preprocessor inconsistency for macros when invoked from gfortran
  2020-03-19 20:01 [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran markwayne1969 at gmail dot com
                   ` (3 preceding siblings ...)
  2020-03-19 22:24 ` markwayne1969 at gmail dot com
@ 2020-03-20  1:12 ` sgk at troutmask dot apl.washington.edu
  2020-03-23  2:41 ` markwayne1969 at gmail dot com
  2020-03-23 16:20 ` sgk at troutmask dot apl.washington.edu
  6 siblings, 0 replies; 8+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2020-03-20  1:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Mar 19, 2020 at 10:24:10PM +0000, markwayne1969 at gmail dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94228
> 
> --- Comment #4 from Mark Paris <markwayne1969 at gmail dot com> ---
> (In reply to kargl from comment #3)
> > No.  Newer C, as opposed to older C, uses // for a comment.
> > Fortran uses // as the concatenation operator.  Run this
> > through a cpp pre-processor.
> > 
> > character(len=80) :: name = 'john ' // 'Doe'
> > print *, name
> > end
> > 
> >  ~/work/bin/cpp a.F
> > # 1 "a.F"
> > # 1 "<built-in>"
> > # 1 "<command-line>"
> > # 1 "a.F"
> > character(len=80) :: name = 'john '
> > print *, name
> > end
> 
> Thank you for your kind reply. I understand that this is an issue
 of disparate use of the same operator, '//' in C and Fortran.
> 
> Is it possible to have cpp recognize the different uses of // by,
> say, the file name extension of the source being processed?

Sure.  Anything is possible if someone puts in the time to
write a Fortran specific preprocessor.  AFAIK, none of the
current diminishing number of gfortran contributors is 
working a new preprocessor.  

> Links to information about gcc development for this specific
> possible feature would be appreciated.

I don't know of any gfortran preprocessor projects.  You are 
more then welcomed to clone the git repository and start
such a project.  Having new gfortran contributors would be
healthy for gfortran's future.

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

* [Bug fortran/94228] Preprocessor inconsistency for macros when invoked from gfortran
  2020-03-19 20:01 [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran markwayne1969 at gmail dot com
                   ` (4 preceding siblings ...)
  2020-03-20  1:12 ` sgk at troutmask dot apl.washington.edu
@ 2020-03-23  2:41 ` markwayne1969 at gmail dot com
  2020-03-23 16:20 ` sgk at troutmask dot apl.washington.edu
  6 siblings, 0 replies; 8+ messages in thread
From: markwayne1969 at gmail dot com @ 2020-03-23  2:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Mark Paris <markwayne1969 at gmail dot com> ---
(In reply to Steve Kargl from comment #5)
> On Thu, Mar 19, 2020 at 10:24:10PM +0000, markwayne1969 at gmail dot com
> wrote:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94228
> > 
> > --- Comment #4 from Mark Paris <markwayne1969 at gmail dot com> ---
> > (In reply to kargl from comment #3)
> > > No.  Newer C, as opposed to older C, uses // for a comment.
> > > Fortran uses // as the concatenation operator.  Run this
> > > through a cpp pre-processor.
> > > 
> > > character(len=80) :: name = 'john ' // 'Doe'
> > > print *, name
> > > end
> > > 
> > >  ~/work/bin/cpp a.F
> > > # 1 "a.F"
> > > # 1 "<built-in>"
> > > # 1 "<command-line>"
> > > # 1 "a.F"
> > > character(len=80) :: name = 'john '
> > > print *, name
> > > end
> > 
> > Thank you for your kind reply. I understand that this is an issue
>  of disparate use of the same operator, '//' in C and Fortran.
> > 
> > Is it possible to have cpp recognize the different uses of // by,
> > say, the file name extension of the source being processed?
> 
> Sure.  Anything is possible if someone puts in the time to
> write a Fortran specific preprocessor.  AFAIK, none of the
> current diminishing number of gfortran contributors is 
> working a new preprocessor.  
> 
> > Links to information about gcc development for this specific
> > possible feature would be appreciated.
> 
> I don't know of any gfortran preprocessor projects.  You are 
> more then welcomed to clone the git repository and start
> such a project.  Having new gfortran contributors would be
> healthy for gfortran's future.

Thank you, again for your reply. It's not exactly the information I was looking
for -- perhaps you're not the right person to ask. If not, you might be able to
point me to the correct group.

I was asking whether you knew of any reason that the existing cpp couldn't be
adjusted to handle the '//' disparity with a filename extension dependency.

If this is possible, then it seems like a minor revision, as opposed to what
you appear to have in mind of writing "a Fortran specific preprocessor," which
sounds like a prohibitive undertaking.

Thanks again.

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

* [Bug fortran/94228] Preprocessor inconsistency for macros when invoked from gfortran
  2020-03-19 20:01 [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran markwayne1969 at gmail dot com
                   ` (5 preceding siblings ...)
  2020-03-23  2:41 ` markwayne1969 at gmail dot com
@ 2020-03-23 16:20 ` sgk at troutmask dot apl.washington.edu
  6 siblings, 0 replies; 8+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2020-03-23 16:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, Mar 23, 2020 at 02:41:23AM +0000, markwayne1969 at gmail dot com wrote:
> 
> (In reply to Steve Kargl from comment #5)
> > 
> > > Links to information about gcc development for this specific
> > > possible feature would be appreciated.
> > 
> > I don't know of any gfortran preprocessor projects.  You are 
> > more then welcomed to clone the git repository and start
> > such a project.  Having new gfortran contributors would be
> > healthy for gfortran's future.
> 
> Thank you, again for your reply. It's not exactly the information
> I was looking for -- perhaps you're not the right person to ask.
> If not, you might be able to point me to the correct group.
> 
> I was asking whether you knew of any reason that the existing cpp
> couldn't be adjusted to handle the '//' disparity with a filename
> extension dependency.
> 
> If this is possible, then it seems like a minor revision, as
> opposed to what you appear to have in mind of writing "a Fortran
> specific preprocessor," which sounds like a prohibitive undertaking.
> 

You can ask on gcc@gcc.gnu.org and fortran@gcc.gnu.org.
I doubt that that will be too profitable.  Good luck.

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

end of thread, other threads:[~2020-03-23 16:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 20:01 [Bug fortran/94228] New: Preprocessor inconsistency for macros when invoked from gfortran markwayne1969 at gmail dot com
2020-03-19 20:07 ` [Bug fortran/94228] " pinskia at gcc dot gnu.org
2020-03-19 21:01 ` markwayne1969 at gmail dot com
2020-03-19 21:48 ` kargl at gcc dot gnu.org
2020-03-19 22:24 ` markwayne1969 at gmail dot com
2020-03-20  1:12 ` sgk at troutmask dot apl.washington.edu
2020-03-23  2:41 ` markwayne1969 at gmail dot com
2020-03-23 16:20 ` sgk at troutmask dot apl.washington.edu

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