This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Kill spurious "pasting would" warnings (was Re: 2.4.0-test7 spurious '##' patches)


On Thu, Aug 31, 2000 at 10:02:45PM -0700, Zack Weinberg wrote:
> On Fri, Sep 01, 2000 at 03:56:40PM +1100, Keith Owens wrote:
> > On Thu, 31 Aug 2000 21:44:16 -0700, 
> > Richard Henderson <rth@twiddle.net> wrote:
> > >On Thu, Aug 31, 2000 at 07:09:00PM +1100, Keith Owens wrote:
> > >> Compiling 2.4.0-test7 with the latest IA64 toolchain, gcc version
> > >> 2.96-ia64-000717 snap 000828.  It complained about various include
> > >> files, "pasting would not give a valid preprocessing token", this
> > >> version of gcc is a bit more paranoid about the use of '##'.
> > >
> > >> -#define dprintk(args...)	dfprintk(FACILITY, ## args)
> > >> +#define dprintk(args...)	dfprintk(FACILITY, args)
> > >
> > >This one isn't.  This is a gcc extension to remove the previous token
> > >if "args" is empty.  So you'd get
> > >
> > >	dfprintk(FACILITY);
> > >instead of
> > >	dfprintk(FACILITY, );
> > 
> > I know about that extension and I originally tried
> > dfprintk(FACILITY , ##args) which is what gcc info recommends, but that
> > still gave a warning message.
> 
> With a snapshot that recent, (FACILITY , ## args) and (FACILITY, ##args) 
> are equivalent.  Older gcc (including 2.95 and all 2.96 up through May
> or so) would delete too much if you used the second form.
> 
> The 'pasting would not give ...' warning is supposed to be suppressed
> in this context, but obviously it isn't working.  I'll look into it.

Hi!

This works for me: VAR_ARGS flag should be checked in the current context,
not current - 1 and other code uses posn - 1 to index into tokens (otherwise
it points to the closing paren).
Ok to commit?

We should probably have some good testcase to check that the warning is
emited where it should and is not where it should not, like:
#define a(x, y, z...) b(x , ## y)
a(x, y, y, z)
should emit the warning while
#define c(x, y, z...) d(x, y , ## z)
c(x, y, y, z)
should not.

2000-09-01  Jakub Jelinek  <jakub@redhat.com>

	* cpplex.c (ON_REST_ARG): Check VAR_ARGS flag of current context,
	use posn - 1 to index into tokens array.
	(maybe_paste_with_next): Adjust caller.

--- gcc/cpplex.c.jj	Fri Sep  1 10:13:33 2000
+++ gcc/cpplex.c	Fri Sep  1 13:37:01 2000
@@ -202,8 +202,8 @@ TOKEN_LEN (token)
 #define CURRENT_CONTEXT(pfile) ((pfile)->contexts + (pfile)->cur_context)
 #define ON_REST_ARG(c) \
  (((c)->flags & VAR_ARGS) \
-  && (c)->u.list->tokens[(c)->posn].val.aux \
-      == (unsigned int) ((c)->u.list->paramc - 1))
+  && ((c)-1)->u.list->tokens[((c)-1)->posn - 1].val.aux \
+      == (unsigned int) (((c)-1)->u.list->paramc - 1))
 
 #define ASSIGN_FLAGS_AND_POS(d, s) \
   do {(d)->flags = (s)->flags & (PREV_WHITE | BOL | PASTE_LEFT); \
@@ -2773,7 +2773,7 @@ maybe_paste_with_next (pfile, token)
 		     the special extended semantics (see above).  */
 		  if (token->type == CPP_COMMA
 		      && IS_ARG_CONTEXT (CURRENT_CONTEXT (pfile))
-		      && ON_REST_ARG (CURRENT_CONTEXT (pfile) - 1))
+		      && ON_REST_ARG (CURRENT_CONTEXT (pfile)))
 		    /* no warning */;
 		  else
 		    cpp_warning (pfile,


	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]