https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93545

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
   Target Milestone|---                         |10.0

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--- libcpp/macro.c.jj   2020-01-31 19:17:47.377126121 +0100
+++ libcpp/macro.c      2020-02-03 10:14:42.447621094 +0100
@@ -336,6 +336,22 @@ unsigned num_expanded_macros_counter = 0
    from macro expansion.  */
 unsigned num_macro_tokens_counter = 0;

+/* Wrapper around cpp_get_token to skip CPP_PADDING tokens
+   and not consume CPP_EOF.  */
+static const cpp_token *
+cpp_get_token_no_padding (cpp_reader *pfile)
+{
+  for (;;)
+    {
+      const cpp_token *ret = cpp_peek_token (pfile, 0);
+      if (ret->type == CPP_EOF)
+       return ret;
+      ret = cpp_get_token (pfile);
+      if (ret->type != CPP_PADDING)
+       return ret;
+    }
+}
+
 /* Handle meeting "__has_include" builtin macro.  */

 static int
@@ -344,10 +360,10 @@ builtin_has_include (cpp_reader *pfile,
   int result = 0;

   pfile->state.angled_headers = true;
-  const cpp_token *token = cpp_get_token (pfile);
+  const cpp_token *token = cpp_get_token_no_padding (pfile);
   bool paren = token->type == CPP_OPEN_PAREN;
   if (paren)
-    token = cpp_get_token (pfile);
+    token = cpp_get_token_no_padding (pfile);
   else
     cpp_error (pfile, CPP_DL_ERROR,
               "missing '(' before \"%s\" operand", NODE_NAME (op));
@@ -379,7 +395,8 @@ builtin_has_include (cpp_reader *pfile,
       XDELETEVEC (fname);
     }

-  if (paren && !SEEN_EOL () && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN)
+  if (paren
+      && cpp_get_token_no_padding (pfile)->type != CPP_CLOSE_PAREN)
     cpp_error (pfile, CPP_DL_ERROR,
               "missing ')' after \"%s\" operand", NODE_NAME (op));


seems to work, will add some testsuite coverage.

Reply via email to