This is the mail archive of the gcc@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]

Re: warning: pasting would not give a valid preprocessing token


On Wed, 6 Sep 2000, Zack Weinberg wrote:

> On Sat, Aug 12, 2000 at 11:18:56AM -0400, Byron Stanoszek wrote:
> > On Fri, 11 Aug 2000, Zack Weinberg wrote:
> > 
> > > Very recent versions of gcc should not give that warning for the
> > > specific case of , ## <rest argument>.
> > 
> > Well, I just tried it on the August 11 snapshot. So unless you put in a patch
> > over the night, it still issues those warnings.
> 
> A month later (apologies)... I believe this has now been fixed.
> Please update and let me know if you still have problems.  You want
> this change:
> 
> 2000-09-04  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.

Close, but no cigar. Actually, it hushed all of the warnings in every single .c
file (about 45 of them individually), except for this one line. I took apart
the .c file and made a small testcase that you can compile as described below.

I do confirm, however, that the other warnings that were caused by ANSI String
Concatenation are gone now.

This is using the CVS 09/06/2000 version:

---
winds:~/mare/src> cat test.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/* tprintf(): prints to a temporary variable 16k in size */
extern char global_buff[16384];
#define tprintf(format, args...) (sprintf(global_buff, format, ## args), \
                                  (char *)global_buff)

extern char *wtime(unsigned long, int);
extern char *center(char *, int, char);

void test()
{
  char buf[256];
  strcpy(buf, center(tprintf("<%s>", strchr(wtime(-1L, 1), ' ')+1), 63, ' '));
}

winds:~/mare/src> gcc -Wall -O3 test.c -c
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
test.c:16:77: warning: pasting would not give a valid preprocessing token
winds:~/mare/src> 

That's what my strcpy() function looked like.
Narrowing down the test case, this code also causes the same warnings:

  char buf[256], *test="Test";
  strcpy(buf, tprintf("<%s>", test));

However both of these do not give the warnings:

  strcpy(buf, tprintf("<>"));

  tprintf("<%s>", test);

The warnings still occur if I use the form ({ sprintf(..); global_buff; })
in the #define.

Hope this helps in tracking down the problem.

-- 
Byron Stanoszek                         Ph: (330) 644-3059
Systems Programmer                      Fax: (330) 644-8110
Commercial Timesharing Inc.             Email: bstanoszek@comtime.com


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