public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/108493] New: Interaction with implicit includes and -traditional-cpp
@ 2023-01-23 11:07 iains at gcc dot gnu.org
  2023-01-23 11:33 ` [Bug modula2/108493] " iains at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: iains at gcc dot gnu.org @ 2023-01-23 11:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108493
           Summary: Interaction with implicit includes and
                    -traditional-cpp
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: iains at gcc dot gnu.org
  Target Milestone: ---

On powerpc-apple-darwin, we -include 'altivec.h' which predefines some relevant
vector stuff...
(This is behind the scenes, not a user action, when the VMX instruction set is
in use, which is essentially always in reality)

The contains the following line
#define vector __vector

-----

before starting ; To be fair, I am not 100% sure if there's also a bug in the
traditional-cpp impl.

----

$ cat t.mod
MODULE T

IMPORT bug ;

BEGIN
END T.

$ cat bug.def

(* vector *)

$ grep vector
/opt/iains/powerpc-apple-darwin9/gcc-13-0-1-wip/lib/gcc/powerpc-apple-darwin9/13.0.1/include/altivec.h 
/* If __APPLE_ALTIVEC__ is defined, the compiler supports 'vector',
#define vector __vector


---- bug.def is preprocessed recursively from the main.

$ gcc/cc1 -E -v -iprefix
/scratch/10-5-leo/gcc-master-wip/gcc/../lib/gcc/powerpc-apple-darwin9/13.0.1/
-isystem gcc/include -isystem gcc/include-fixed -iplugindir=gcc/plugin -D
__DYNAMIC__  -iplugindir=gcc/plugin -fPIC -dumpbase t.mod -dumpbase-ext .mod
-mmacosx-version-min=10.5.0 -traditional-cpp -version bug.def

# 0 "<command-line>"
# 1 "bug.def"
bug.def:2: error: detected recursion whilst expanding macro "vector"
    2 | (* vector *)

regular CPP does not exhibit this problem - is there a reason we need to use
"traditional" ?

As noted there could be a bug with the preprocessor too .. I do not know.

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

* [Bug modula2/108493] Interaction with implicit includes and -traditional-cpp
  2023-01-23 11:07 [Bug modula2/108493] New: Interaction with implicit includes and -traditional-cpp iains at gcc dot gnu.org
@ 2023-01-23 11:33 ` iains at gcc dot gnu.org
  2023-01-23 12:14 ` [Bug target/108493] Interaction with builtin_defines (on PowerPC) " iains at gcc dot gnu.org
  2024-01-29  7:35 ` gaius at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: iains at gcc dot gnu.org @ 2023-01-23 11:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
I can reproduce this with C - so it's not specifically a module-2 issue (but
the use of traditional-cpp does trigger it .. and for keywords within (* *) so
we need to figure out what the intended semantics are.

----

# 0 "t.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "t.c"
t.c:2: error: detected recursion whilst expanding macro "vector"
    2 | vector X;
      | 

vector X;

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

* [Bug target/108493] Interaction with builtin_defines (on PowerPC) and -traditional-cpp
  2023-01-23 11:07 [Bug modula2/108493] New: Interaction with implicit includes and -traditional-cpp iains at gcc dot gnu.org
  2023-01-23 11:33 ` [Bug modula2/108493] " iains at gcc dot gnu.org
@ 2023-01-23 12:14 ` iains at gcc dot gnu.org
  2024-01-29  7:35 ` gaius at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: iains at gcc dot gnu.org @ 2023-01-23 12:14 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Target|                            |powerpc-darwin,
                   |                            |powerpc64-linux-gnu
          Component|modula2                     |target
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-01-23
           Assignee|gaius at gcc dot gnu.org           |unassigned at gcc dot gnu.org
            Summary|Interaction with implicit   |Interaction with
                   |includes and                |builtin_defines (on
                   |-traditional-cpp            |PowerPC) and
                   |                            |-traditional-cpp

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
this repeats on linux-gnu.

There are the following defines in gcc/config/rs6000/rs6000-c.cc (conditional
on !iso) :
  builtin_define ("vector=vector");
  builtin_define ("pixel=pixel");
  builtin_define ("bool=bool");
  builtin_define ("_Bool=_Bool");

they've been there since 2008 .. so I guess no-one cares ( until the modula-2
case triggers it ).

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

* [Bug target/108493] Interaction with builtin_defines (on PowerPC) and -traditional-cpp
  2023-01-23 11:07 [Bug modula2/108493] New: Interaction with implicit includes and -traditional-cpp iains at gcc dot gnu.org
  2023-01-23 11:33 ` [Bug modula2/108493] " iains at gcc dot gnu.org
  2023-01-23 12:14 ` [Bug target/108493] Interaction with builtin_defines (on PowerPC) " iains at gcc dot gnu.org
@ 2024-01-29  7:35 ` gaius at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-01-29  7:35 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |gaius at gcc dot gnu.org

--- Comment #3 from Gaius Mulley <gaius at gcc dot gnu.org> ---
I wonder if writing a filter program to strip comments out before cpp would fix
the problem.

The filter program (m2decom) would strip out any comment which does not have
'#' in the first column (and honour line continuation backslashes etc).  This
would allow the debugging technique in gcc/m2/gm2-libs/FormatStrings.mod to
work.

If I recall correctly the reason cpp -traditional is required is because ' is a
start of string character in m2 (so is ").  But the m2 string formed: '\'
causes:

$ gcc -x c -E ~/GCC/gcc-read-write/gcc/m2/gm2-libs/FormatStrings.mod
   <snip>
   DSdbEnter ;
   d := InitString ('') ;
/home/gaius/GCC/gcc-read-write/gcc/m2/gm2-libs/FormatStrings.mod:196:19:
warning: missing terminating ' character
  196 |    i := Index (s, '\', 0) ;
      |                   ^
   i := Index (s, '\', 0) ;

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

end of thread, other threads:[~2024-01-29  7:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23 11:07 [Bug modula2/108493] New: Interaction with implicit includes and -traditional-cpp iains at gcc dot gnu.org
2023-01-23 11:33 ` [Bug modula2/108493] " iains at gcc dot gnu.org
2023-01-23 12:14 ` [Bug target/108493] Interaction with builtin_defines (on PowerPC) " iains at gcc dot gnu.org
2024-01-29  7:35 ` gaius at gcc dot gnu.org

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