]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libcpp/charset.c
tree-optimization/95495 - use SLP_TREE_REPRESENTATIVE in assertion
[thirdparty/gcc.git] / libcpp / charset.c
index 956d2dad5c86079bbd8644fb261dc167cfd64e11..db47235b84718bc80a52bd95727f71ff1e01dde8 100644 (file)
@@ -1,5 +1,5 @@
 /* CPP Library - charsets
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
 
    Broken out of c-lex.c Apr 2003, adding valid C99 UCN ranges.
 
@@ -1021,7 +1021,7 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c,
 
    If the hexadecimal value is larger than the upper bound of the UCS
    codespace specified in ISO/IEC 10646, a pedantic warning is issued
-   in all versions of C and in the C++2a or later versions of C++.
+   in all versions of C and in the C++20 or later versions of C++.
 
    *PSTR must be preceded by "\u" or "\U"; it is assumed that the
    buffer end is delimited by a non-hex digit.  Returns false if the
@@ -1970,6 +1970,17 @@ wide_str_to_charconst (cpp_reader *pfile, cpp_string str,
   size_t off, i;
   cppchar_t result = 0, c;
 
+  if (str.len <= nbwc)
+    {
+      /* Error recovery, if no errors have been diagnosed previously,
+        there should be at least two wide characters.  Empty literals
+        are diagnosed earlier and we can get just the zero terminator
+        only if there were errors diagnosed during conversion.  */
+      *pchars_seen = 0;
+      *unsignedp = 0;
+      return 0;
+    }
+
   /* This is finicky because the string is in the target's byte order,
      which may not be our byte order.  Only the last character, ignoring
      the NUL terminator, is relevant.  */
@@ -2237,7 +2248,6 @@ _cpp_default_encoding (void)
 cpp_string_location_reader::
 cpp_string_location_reader (location_t src_loc,
                            line_maps *line_table)
-: m_line_table (line_table)
 {
   src_loc = get_range_from_loc (line_table, src_loc).m_start;