From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeffrey A Law To: Neil Booth Cc: Byron Stanoszek , geoffk@cygnus.com, gcc@gcc.gnu.org, gcc-patches@gcc.gnu.org, jakub@redhat.com Subject: Re: warning: pasting would not give a valid preprocessing token Date: Thu, 14 Sep 2000 16:08:00 -0000 Message-id: <7437.968972879@upchuck> References: <20000914235302.A9969@daikokuya.demon.co.uk> X-SW-Source: 2000-09/msg00328.html In message < 20000914235302.A9969@daikokuya.demon.co.uk >you write: > [There's no point cc-ing Zack; his mail address is no more] > > Byron, > > I hope this fixes it for you. I'm bootstrapping now, and will then > run the testsuite. > > This area is a bit ugly and in bad need of a cleanup. I need to > extract more flexibility from the lexer first, though. The problem > was in the way we handle macro arguments: each argument is a list of > pointers to the tokens making up the argument. These tend to point to > the original tokens (in this case, the comma in the macro definition > in the hash table). That token has a PASTE_LEFT flag to say it's on > the left hand side of a ##. The problem is that after processing the > paste, and correctly not emitting a warning about invalid pastes, we > maintained a pointer to the same comma for the nested macro > replacements (since it is part of an argument itself). Unforunately, > of course, that comma still has its paste flag set, so the paste > mechanism gets re-invoked in later unintended places; hence the > (repeated) warnings. > > This is a nice testcase for quite a deep nested macro bug. I > simplified your case to the one below, which I'll commit along with > the fix. If you have a chance, please give it a whirl. > > It also fixes a bug in ON_REST_ARG - the macro was testing the flags > of the wrong thing (easy to do since #defines are typeless). Any > relief the original fix brought might therefore be undone; I'd be > interested in knowing if the warnings it "cured" come back with this > patch. > > OK to commit? > > Neil. > > * cpplex.c (ON_REST_ARG): Correct the test. > (maybe_paste_with_next): Duplicate a token that fail pasting, > and clear its PASTE_LEFT flag, so that nested pasting attempts > do not occur. > * gcc.dg/cpp/paste10.c: Testcase. Assuming the bootstrap & test passes, this is fine to install. jeff