Message ID | 20150401112428.GL19273@tucnak.redhat.com |
---|---|
State | New |
Headers | show |
On 04/01/2015 07:24 AM, Jakub Jelinek wrote: > Below is one possible fix for that, another option is introduce another > pfile->state or pfile field for that, I notice that pfile->state.skipping suppresses the line change as well as various diagnostics that also seem inappropriate for peeking. Perhaps we could use a new state field instead in those places, and only check state.skipping for the actual skipping behavior. But this patch is fine if you don't want to bother with that. Jason
On Wed, Apr 01, 2015 at 04:23:12PM -0400, Jason Merrill wrote: > On 04/01/2015 07:24 AM, Jakub Jelinek wrote: > >Below is one possible fix for that, another option is introduce another > >pfile->state or pfile field for that, > > I notice that pfile->state.skipping suppresses the line change as well as > various diagnostics that also seem inappropriate for peeking. Perhaps we > could use a new state field instead in those places, and only check > state.skipping for the actual skipping behavior. I was thinking about that, but e.g. warnings like warn_about_normalization only happen during _cpp_lex_direct and thus would not be reported at all if they were skipped during cpp_peek_token. Jakub
--- libcpp/lex.c.jj 2015-03-31 19:39:28.000000000 +0200 +++ libcpp/lex.c 2015-04-01 12:03:31.146846380 +0200 @@ -2080,6 +2080,12 @@ cpp_peek_token (cpp_reader *pfile, int i count = index; pfile->keep_tokens++; + /* For peeked tokens temporarily disable line_change reporting, + until the tokens are parsed for real. */ + void (*line_change) (cpp_reader *, const cpp_token *, int) + = pfile->cb.line_change; + pfile->cb.line_change = NULL; + do { peektok = _cpp_lex_token (pfile); @@ -2093,6 +2099,7 @@ cpp_peek_token (cpp_reader *pfile, int i _cpp_backup_tokens_direct (pfile, count - index); pfile->keep_tokens--; + pfile->cb.line_change = line_change; return peektok; } --- gcc/testsuite/gcc.target/powerpc/pr61977-1.c.jj 2015-04-01 12:15:15.341311939 +0200 +++ gcc/testsuite/gcc.target/powerpc/pr61977-1.c 2015-04-01 12:17:32.030102843 +0200 @@ -0,0 +1,8 @@ +/* PR preprocessor/61977 */ +/* { dg-do preprocess } */ +/* { dg-options "-mno-altivec -mno-vsx" } */ + +int y; vector +int x; + +/* { dg-final { scan-file "pr61977-1.i" "(^|\\n)int y; vector\\n" } } */ --- gcc/testsuite/gcc.target/powerpc/pr61977-2.c.jj 2015-04-01 12:15:18.125266339 +0200 +++ gcc/testsuite/gcc.target/powerpc/pr61977-2.c 2015-04-01 12:18:22.033321600 +0200 @@ -0,0 +1,8 @@ +/* PR preprocessor/61977 */ +/* { dg-do preprocess } */ +/* { dg-options "-maltivec" } */ + +int y; vector +int x; + +/* { dg-final { scan-file "pr61977-2.i" "(^|\\n)int y; __attribute__\\(\\(altivec\\(vector__\\)\\)\\)\\n" } } */