[1/7] Preprocessor cleanup
[gcc.git] / libcpp / charset.c
index e77270a18eb957e29f4a5e391a4969f1a2fb0ce0..36c57a6a04673b65cd85888d1bd354bdd7bfff6e 100644 (file)
@@ -1,5 +1,5 @@
 /* CPP Library - charsets
-   Copyright (C) 1998-2016 Free Software Foundation, Inc.
+   Copyright (C) 1998-2018 Free Software Foundation, Inc.
 
    Broken out of c-lex.c Apr 2003, adding valid C99 UCN ranges.
 
@@ -1564,10 +1564,21 @@ cpp_interpret_string_1 (cpp_reader *pfile, const cpp_string *from, size_t count,
 
          /* Skip over 'R"'.  */
          p += 2;
+         if (loc_reader)
+           {
+             loc_reader->get_next ();
+             loc_reader->get_next ();
+           }
          prefix = p;
          while (*p != '(')
-           p++;
+           {
+             p++;
+             if (loc_reader)
+               loc_reader->get_next ();
+           }
          p++;
+         if (loc_reader)
+           loc_reader->get_next ();
          limit = from[i].text + from[i].len;
          if (limit >= p + (p - prefix) + 1)
            limit -= (p - prefix) + 1;
@@ -1682,13 +1693,14 @@ cpp_interpret_string (cpp_reader *pfile, const cpp_string *from, size_t count,
   return cpp_interpret_string_1 (pfile, from, count, to, type, NULL, NULL);
 }
 
-/* A "do nothing" error-handling callback for use by
+/* A "do nothing" diagnostic-handling callback for use by
    cpp_interpret_string_ranges, so that it can temporarily suppress
-   error-handling.  */
+   diagnostic-handling.  */
 
 static bool
-noop_error_cb (cpp_reader *, int, int, rich_location *,
-              const char *, va_list *)
+noop_diagnostic_cb (cpp_reader *, enum cpp_diagnostic_level,
+                   enum cpp_warning_reason, rich_location *,
+                   const char *, va_list *)
 {
   /* no-op.  */
   return true;
@@ -1726,25 +1738,26 @@ cpp_interpret_string_ranges (cpp_reader *pfile, const cpp_string *from,
     return "execution character set != source character set";
 
   /* For on-demand strings we have already lexed the strings, so there
-     should be no errors.  However, if we have bogus source location
+     should be no diagnostics.  However, if we have bogus source location
      data (or stringified macro arguments), the attempt to lex the
-     strings could fail with an error.  Temporarily install an
-     error-handler to catch the error, so that it can lead to this call
+     strings could fail with an diagnostic.  Temporarily install an
+     diagnostic-handler to catch the diagnostic, so that it can lead to this call
      failing, rather than being emitted as a user-visible diagnostic.
-     If an error does occur, we should see it via the return value of
+     If an diagnostic does occur, we should see it via the return value of
      cpp_interpret_string_1.  */
-  bool (*saved_error_handler) (cpp_reader *, int, int, rich_location *,
-                              const char *, va_list *)
+  bool (*saved_diagnostic_handler) (cpp_reader *, enum cpp_diagnostic_level,
+                                   enum cpp_warning_reason, rich_location *,
+                                   const char *, va_list *)
     ATTRIBUTE_FPTR_PRINTF(5,0);
 
-  saved_error_handler = pfile->cb.error;
-  pfile->cb.error = noop_error_cb;
+  saved_diagnostic_handler = pfile->cb.diagnostic;
+  pfile->cb.diagnostic = noop_diagnostic_cb;
 
   bool result = cpp_interpret_string_1 (pfile, from, count, NULL, type,
                                        loc_readers, out);
 
-  /* Restore the saved error-handler.  */
-  pfile->cb.error = saved_error_handler;
+  /* Restore the saved diagnostic-handler.  */
+  pfile->cb.diagnostic = saved_diagnostic_handler;
 
   if (!result)
     return "cpp_interpret_string_1 failed";