public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: preprocessor/3852: cpp: parantheses wrong in variable argument macros
@ 2001-07-28 3:58 neil
0 siblings, 0 replies; 2+ messages in thread
From: neil @ 2001-07-28 3:58 UTC (permalink / raw)
To: asbrown, gcc-bugs, gcc-prs, nobody
Synopsis: cpp: parantheses wrong in variable argument macros
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Sat Jul 28 03:58:21 2001
State-Changed-Why:
3.0 gives the much prettier:-
$ cpp /tmp/test.c
# 9 "/tmp/test.c"
void main() {
(0);
(0, (0));
(0, 0);
(0);
}
which is what I imagine you wanted. It's good to know this is fixed;
I didn't realise there were bugs in 2.95.2 macro varargs. 3.0 is completely
rewritten from scratch.
Yours is an interesting testcase. Do you mind if I butcher it into test suite
form?
Neil.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3852&database=gcc
^ permalink raw reply [flat|nested] 2+ messages in thread
* preprocessor/3852: cpp: parantheses wrong in variable argument macros
@ 2001-07-27 19:16 asbrown
0 siblings, 0 replies; 2+ messages in thread
From: asbrown @ 2001-07-27 19:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 3852
>Category: preprocessor
>Synopsis: cpp: parantheses wrong in variable argument macros
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jul 27 19:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: asbrown@ati.com
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
sparc-sun-solaris2.6
>Description:
I was using the variable macro arguments feature of cpp and I noticed some problems with the parantheses. I haven't tried it on gcc 3.0.
Here is the source to test.c:
// here's something that works
#define TEST_GOOD(foo, args...) (foo, ## args)
// here's a variation that doesn't
#define TEST_BAD(foo, args...) (0, (foo), ## args)
// this is simpler and needs an argument to work
#define TEST_WORSE(args...) (0, ## args)
void main() {
TEST_GOOD(0); // works
TEST_BAD(0); // doesn't work
TEST_WORSE(0); // works
TEST_WORSE(); // doesn't work
}
If I run cpp test.c, I get
# 1 "test.c"
void main() {
( 0 ) ;
(0, ( 0 ) ;
(0,0 ) ;
) ;
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-07-28 3:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-28 3:58 preprocessor/3852: cpp: parantheses wrong in variable argument macros neil
-- strict thread matches above, loose matches on Subject: below --
2001-07-27 19:16 asbrown
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).