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

* 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.dg/cpp/paste8.c: New test.

From-SVN: r36128
This commit is contained in:
Jakub Jelinek 2000-09-04 09:51:58 +02:00 committed by Jakub Jelinek
parent e4e37381ca
commit 29844fa7c7
4 changed files with 28 additions and 3 deletions

View File

@ -1,3 +1,9 @@
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.
2000-09-03 Geoff Keating <geoffk@cygnus.com>
* invoke.texi: Document the -mvxworks option for rs6000 ELF.

View File

@ -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,

View File

@ -1,3 +1,7 @@
2000-09-04 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/cpp/paste8.c: New test.
2000-09-01 Alexandre Oliva <aoliva@redhat.com>
* gcc.c-torture/compile/20000827-1.c: New test.

View File

@ -0,0 +1,15 @@
/* { dg-do preprocess } */
/* { dg-options "" } */
int foo(int, ...);
#define a(x, y...) foo(x, ##y)
a(1)
a(1, 2, 3)
#define b(x, y, z...) foo(x, ##y)
b(1, 2, 3) /* { dg-warning "pasting would not" } */
#define c(x, y, z...) foo(x, ##z)
c(1, 2)
c(1, 2, 3)
#define d(x) foo(##x) /* { dg-warning "nothing can be pasted" } */
d(1)