On Wed, May 19, 2021 at 09:54:07AM +0200, Jakub Jelinek wrote:
> Hi!
> 
> As can be seen on the testcases, before the -fdirectives-only preprocessing
> rewrite the preprocessor would assume // comments are terminated by the
> end of file even when newline wasn't there, but now we error out.
> The following patch restores the previous behavior.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2021-05-19  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR preprocessor/100646
>       * lex.c (cpp_directive_only_process): Treat end of file as termination
>       for !is_block comments.
> 
>       * gcc.dg/cpp/pr100646-1.c: New test.
>       * gcc.dg/cpp/pr100646-2.c: New test.
> 
> --- libcpp/lex.c.jj   2021-05-12 15:13:57.000000000 +0200
> +++ libcpp/lex.c      2021-05-18 19:48:04.211383565 +0200
> @@ -4480,6 +4480,8 @@ cpp_directive_only_process (cpp_reader *
>                       break;
>                     }
>                 }
> +             if (pos >= limit && !is_block)
> +               goto done_comment;

The goto seems unnecessary since we're only skipping...

>               cpp_error_with_line (pfile, CPP_DL_ERROR, sloc, 0,
>                                    "unterminated comment");

...this line, so just adjust the condition?  Were you just trying to be
consistent with the gotos above?

The patch is OK either way.

>             done_comment:

Marek

Reply via email to