public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/37549] New: gcc -E -dD prints predefined macros, contrary to docs
@ 2008-09-17 2:26 martinrb at google dot com
2008-09-17 3:13 ` Andrew Thomas Pinski
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: martinrb at google dot com @ 2008-09-17 2:26 UTC (permalink / raw)
To: gcc-bugs
The docs for preprocessor -dD flag states
`D'
Like `M' except in two respects: it does _not_ include the
predefined macros
So one would expect -dD and -dM to differ substantially.
But....
(martinrb@spraggett) ~ $ gcc -E -dM -x c /dev/null | sort >/tmp/t1
(martinrb@spraggett) ~ $ gcc -E -dD -x c /dev/null | sort >/tmp/t2
(martinrb@spraggett) ~ $ diff /tmp/t[12]
0a1,4
> # 1 "<built-in>"
> # 1 "<command-line>"
> # 1 "/dev/null"
> # 1 "/dev/null"
(martinrb@spraggett) ~ $ wc /tmp/t[12]
111 340 3482 /tmp/t1
115 352 3552 /tmp/t2
226 692 7034 total
(martinrb@spraggett) ~ $ gcc --version
gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
--
Summary: gcc -E -dD prints predefined macros, contrary to docs
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: martinrb at google dot com
GCC host triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37549
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Bug preprocessor/37549] New: gcc -E -dD prints predefined macros, contrary to docs
2008-09-17 2:26 [Bug preprocessor/37549] New: gcc -E -dD prints predefined macros, contrary to docs martinrb at google dot com
@ 2008-09-17 3:13 ` Andrew Thomas Pinski
2008-09-17 3:15 ` [Bug preprocessor/37549] " pinskia at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andrew Thomas Pinski @ 2008-09-17 3:13 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
Sent from my iPhone
On Sep 16, 2008, at 7:25 PM, "martinrb at google dot com" <gcc-bugzilla@gcc.gnu.org
> wrote:
> The docs for preprocessor -dD flag states
>
> `D'
> Like `M' except in two respects: it does _not_ include the
> predefined macros
I think what it means by predefines are the ones included on the
command line that are defined by the user via -D.
>
>
> So one would expect -dD and -dM to differ substantially.
> But....
>
> (martinrb@spraggett) ~ $ gcc -E -dM -x c /dev/null | sort >/tmp/t1
> (martinrb@spraggett) ~ $ gcc -E -dD -x c /dev/null | sort >/tmp/t2
> (martinrb@spraggett) ~ $ diff /tmp/t[12]
> 0a1,4
>> # 1 "<built-in>"
>> # 1 "<command-line>"
>> # 1 "/dev/null"
>> # 1 "/dev/null"
> (martinrb@spraggett) ~ $ wc /tmp/t[12]
> 111 340 3482 /tmp/t1
> 115 352 3552 /tmp/t2
> 226 692 7034 total
> (martinrb@spraggett) ~ $ gcc --version
> gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
>
>
> --
> Summary: gcc -E -dD prints predefined macros, contrary to
> docs
> Product: gcc
> Version: 4.2.3
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: preprocessor
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: martinrb at google dot com
> GCC host triplet: x86_64-linux-gnu
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37549
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug preprocessor/37549] gcc -E -dD prints predefined macros, contrary to docs
2008-09-17 2:26 [Bug preprocessor/37549] New: gcc -E -dD prints predefined macros, contrary to docs martinrb at google dot com
2008-09-17 3:13 ` Andrew Thomas Pinski
@ 2008-09-17 3:15 ` pinskia at gmail dot com
2008-09-17 4:28 ` martinrb at google dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gmail dot com @ 2008-09-17 3:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gmail dot com 2008-09-17 03:13 -------
Subject: Re: New: gcc -E -dD prints predefined macros, contrary to docs
Sent from my iPhone
On Sep 16, 2008, at 7:25 PM, "martinrb at google dot com"
<gcc-bugzilla@gcc.gnu.org
> wrote:
> The docs for preprocessor -dD flag states
>
> `D'
> Like `M' except in two respects: it does _not_ include the
> predefined macros
I think what it means by predefines are the ones included on the
command line that are defined by the user via -D.
>
>
> So one would expect -dD and -dM to differ substantially.
> But....
>
> (martinrb@spraggett) ~ $ gcc -E -dM -x c /dev/null | sort >/tmp/t1
> (martinrb@spraggett) ~ $ gcc -E -dD -x c /dev/null | sort >/tmp/t2
> (martinrb@spraggett) ~ $ diff /tmp/t[12]
> 0a1,4
>> # 1 "<built-in>"
>> # 1 "<command-line>"
>> # 1 "/dev/null"
>> # 1 "/dev/null"
> (martinrb@spraggett) ~ $ wc /tmp/t[12]
> 111 340 3482 /tmp/t1
> 115 352 3552 /tmp/t2
> 226 692 7034 total
> (martinrb@spraggett) ~ $ gcc --version
> gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
>
>
> --
> Summary: gcc -E -dD prints predefined macros, contrary to
> docs
> Product: gcc
> Version: 4.2.3
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: preprocessor
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: martinrb at google dot com
> GCC host triplet: x86_64-linux-gnu
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37549
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37549
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug preprocessor/37549] gcc -E -dD prints predefined macros, contrary to docs
2008-09-17 2:26 [Bug preprocessor/37549] New: gcc -E -dD prints predefined macros, contrary to docs martinrb at google dot com
2008-09-17 3:13 ` Andrew Thomas Pinski
2008-09-17 3:15 ` [Bug preprocessor/37549] " pinskia at gmail dot com
@ 2008-09-17 4:28 ` martinrb at google dot com
2009-03-30 0:40 ` jsm28 at gcc dot gnu dot org
2009-03-30 23:22 ` tromey at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: martinrb at google dot com @ 2008-09-17 4:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from martinrb at google dot com 2008-09-17 04:27 -------
I tried to check how -dM and -dD treats macros defined on the command line
and in the source file:
(martinrb@spraggett) ~/src/toy $ cat foo.c
#define FOO 1
(martinrb@spraggett) ~/src/toy $ gcc -E -dM -x c -DBAR=1 foo.c | sort >/tmp/t1
(martinrb@spraggett) ~/src/toy $ gcc -E -dD -x c -DBAR=1 foo.c | sort >/tmp/t2
(martinrb@spraggett) ~/src/toy $ diff /tmp/t[12]
0a1,4
> # 1 "<built-in>"
> # 1 "<command-line>"
> # 1 "foo.c"
> # 1 "foo.c"
=> No difference in the treatment of various classes of macros.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37549
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug preprocessor/37549] gcc -E -dD prints predefined macros, contrary to docs
2008-09-17 2:26 [Bug preprocessor/37549] New: gcc -E -dD prints predefined macros, contrary to docs martinrb at google dot com
` (2 preceding siblings ...)
2008-09-17 4:28 ` martinrb at google dot com
@ 2009-03-30 0:40 ` jsm28 at gcc dot gnu dot org
2009-03-30 23:22 ` tromey at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 0:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jsm28 at gcc dot gnu dot org 2009-03-30 00:39 -------
It seems -dD used not to print predefined macros (whether defined by the
compiler or the user) but this changed in 3.0. Since the documentation did
not change, I will guess the change was not deliberate.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-03-30 00:39:56
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37549
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug preprocessor/37549] gcc -E -dD prints predefined macros, contrary to docs
2008-09-17 2:26 [Bug preprocessor/37549] New: gcc -E -dD prints predefined macros, contrary to docs martinrb at google dot com
` (3 preceding siblings ...)
2009-03-30 0:40 ` jsm28 at gcc dot gnu dot org
@ 2009-03-30 23:22 ` tromey at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: tromey at gcc dot gnu dot org @ 2009-03-30 23:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from tromey at gcc dot gnu dot org 2009-03-30 23:22 -------
Try this.
I'll submit it if it regression tests ok.
Index: c-ppoutput.c
===================================================================
--- c-ppoutput.c (revision 145295)
+++ c-ppoutput.c (working copy)
@@ -377,6 +380,8 @@
static void
cb_define (cpp_reader *pfile, source_location line, cpp_hashnode *node)
{
+ if (line <= BUILTINS_LOCATION)
+ return;
maybe_print_line (line);
fputs ("#define ", print.outf);
@@ -396,6 +401,8 @@
cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
cpp_hashnode *node)
{
+ if (line <= BUILTINS_LOCATION)
+ return;
maybe_print_line (line);
fprintf (print.outf, "#undef %s\n", NODE_NAME (node));
print.src_line++;
--
tromey at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37549
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-03-30 23:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-17 2:26 [Bug preprocessor/37549] New: gcc -E -dD prints predefined macros, contrary to docs martinrb at google dot com
2008-09-17 3:13 ` Andrew Thomas Pinski
2008-09-17 3:15 ` [Bug preprocessor/37549] " pinskia at gmail dot com
2008-09-17 4:28 ` martinrb at google dot com
2009-03-30 0:40 ` jsm28 at gcc dot gnu dot org
2009-03-30 23:22 ` tromey at gcc dot gnu dot 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).