This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __VA_ARGS__ patch for cccp.c
- To: Marc Lehmann <pcg at goof dot com>
- Subject: Re: __VA_ARGS__ patch for cccp.c
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Mon, 09 Mar 1998 18:34:04 -0800
- cc: egcs at cygnus dot com, wilson at cygnus dot com
This small patch enables variable arguments for macros in the same style as
in my copy of the draft c9x standard.
We really should have a way of specifying the c9x standard before adding
features that are specific to it. I'll bring that up in another message.
it essentially treats ... as __VA_ARGS__..., as in:
This looks mostly OK. However, I don't see anything in the C9X draft about
using ## to delete a preceeding argument if the ... part is empty. This stuff
should not be enabled if using the c9x style variable argument macros.
This happens at this comment:
/* If followed by an empty rest arg with concatenation,
Maybe we could use a different value for the rest_args field to distinguish
between these two different cases.
note also that this is always enabled (it doesn't clash with the older
syntax), as was the arg... syntax (hmm, why is this enabled even with
-pedantic?)
That looks like a bug to me. This patch seems to fix it.
Mon Mar 9 18:13:09 1998 Jim Wilson <wilson@cygnus.com>
* cccp.c (create_definition): If pedantic, call pedwarn for macro
varargs feature.
Index: cccp.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cccp.c,v
retrieving revision 1.15
diff -p -r1.15 cccp.c
*** cccp.c 1998/03/06 23:54:33 1.15
--- cccp.c 1998/03/10 02:13:03
*************** create_definition (buf, limit, op)
*** 5565,5570 ****
--- 5565,5572 ----
/* do we have a "special" rest-args extension here? */
if (limit - bp > REST_EXTENSION_LENGTH
&& bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0) {
+ if (pedantic)
+ pedwarn ("ANSI C does not allow macro with variable arguments");
rest_args = 1;
temp->rest_args = 1;
break;