[PATCH] Fix __has_include error recovery in libcpp (PR preprocessor/88974)

Jakub Jelinek jakub@redhat.com
Fri Jan 25 05:40:00 GMT 2019


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.

> Do we still give this diagnostic if there is a closing > but no )?

Yes:
#if __has_include (<abc.h>
#endif
a.c:1:26: error: unterminated argument list invoking macro "__has_include"
    1 | #if __has_include (<abc.h>
      |                          ^
pfile->cur_token[-1].type in that case is CPP_GREATER, or for
__has_include ("abc.h"
is CPP_STRING etc.

	Jakub



More information about the Gcc-patches mailing list