On Fri, Jan 25, 2019 at 09:31:18AM -0500, Jason Merrill wrote: > On 1/25/19 12:15 AM, Jakub Jelinek wrote: > > On Thu, Jan 24, 2019 at 05:16:52PM -0500, Jason Merrill wrote: > > > > --- libcpp/expr.c.jj 2019-01-01 12:38:16.132007335 +0100 > > > > +++ libcpp/expr.c 2019-01-24 14:07:10.080774120 +0100 > > > > @@ -2238,7 +2238,9 @@ parse_has_include (cpp_reader *pfile, en > > > > XDELETEVEC (fname); > > > > } > > > > - if (paren && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN) > > > > + if (paren > > > > + && pfile->cur_token[-1].type != CPP_EOF > > > > > > Is there a reason not to use the SEEN_EOL macro here, too (first moving it > > > into a header)? > > > > I can move it if you want to internal.h. > > OK with that change.
Here is what I've committed after another bootstrap/regtest on {x86_64,i686}-linux. Thanks. 2019-01-26 Jakub Jelinek <ja...@redhat.com> PR preprocessor/88974 * directives.c (SEEN_EOL): Move macro to ... * internal.h (SEEN_EOL): ... here. * expr.c (parse_has_include): Don't cpp_get_token if SEEN_EOL (). * c-c++-common/cpp/pr88974.c: New test. --- libcpp/directives.c.jj 2019-01-24 19:08:45.000000000 +0100 +++ libcpp/directives.c 2019-01-25 21:31:22.755442351 +0100 @@ -204,8 +204,6 @@ static const directive linemarker_dir = do_linemarker, UC"#", 1, KANDR, IN_I }; -#define SEEN_EOL() (pfile->cur_token[-1].type == CPP_EOF) - /* Skip any remaining tokens in a directive. */ static void skip_rest_of_line (cpp_reader *pfile) --- libcpp/internal.h.jj 2019-01-24 19:08:45.000000000 +0100 +++ libcpp/internal.h 2019-01-25 21:33:00.339379400 +0100 @@ -593,6 +593,8 @@ struct cpp_reader #define is_nvspace(x) IS_NVSPACE(x) #define is_space(x) IS_SPACE_OR_NUL(x) +#define SEEN_EOL() (pfile->cur_token[-1].type == CPP_EOF) + /* This table is constant if it can be initialized at compile time, which is the case if cpp was compiled with GCC >=2.7, or another compiler that supports C99. */ --- libcpp/expr.c.jj 2019-01-24 19:08:45.147042475 +0100 +++ libcpp/expr.c 2019-01-25 21:34:22.098500546 +0100 @@ -2238,7 +2238,7 @@ parse_has_include (cpp_reader *pfile, en XDELETEVEC (fname); } - if (paren && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN) + if (paren && !SEEN_EOL () && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN) cpp_error (pfile, CPP_DL_ERROR, "missing ')' after \"__has_include__\""); --- gcc/testsuite/c-c++-common/cpp/pr88974.c.jj 2019-01-24 14:25:02.271100711 +0100 +++ gcc/testsuite/c-c++-common/cpp/pr88974.c 2019-01-24 14:24:48.098334156 +0100 @@ -0,0 +1,6 @@ +/* PR preprocessor/88974 */ +/* { dg-do preprocess } */ + +#if __has_include (<pr88974.h) +/* { dg-error "missing terminating > character" "" { target *-*-* } .-1 } */ +#endif Jakub