diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2015-07-02 18:54:41 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-07-02 18:54:41 +0000 |
commit | fbb22910cfa4e4567b46fc8b74ccfad92fa745d8 (patch) | |
tree | 2aac293a422c002719640bf2767fde8c557ab77b /libcpp/charset.c | |
parent | a05d02b293b299352b9523875e96bf697f96baf4 (diff) | |
download | gcc-fbb22910cfa4e4567b46fc8b74ccfad92fa745d8.zip gcc-fbb22910cfa4e4567b46fc8b74ccfad92fa745d8.tar.gz gcc-fbb22910cfa4e4567b46fc8b74ccfad92fa745d8.tar.bz2 |
re PR preprocessor/53690 ([C++11] \u0000 and \U00000000 are wrongly encoded as U+0001.)
/libcpp
2015-07-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53690
* charset.c (_cpp_valid_ucn): Add cppchar_t * parameter and change
return type to bool. Fix encoding of \u0000 and \U00000000 in C++.
(convert_ucn): Adjust call.
* lex.c (forms_identifier_p): Likewise.
* internal.h (_cpp_valid_ucn): Adjust declaration.
/gcc/testsuite
2015-07-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53690
* g++.dg/cpp/pr53690.C: New.
From-SVN: r225353
Diffstat (limited to 'libcpp/charset.c')
-rw-r--r-- | libcpp/charset.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libcpp/charset.c b/libcpp/charset.c index 8e92bc6..5a1c929 100644 --- a/libcpp/charset.c +++ b/libcpp/charset.c @@ -972,21 +972,20 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c, or 0060 (`), nor one in the range D800 through DFFF inclusive. *PSTR must be preceded by "\u" or "\U"; it is assumed that the - buffer end is delimited by a non-hex digit. Returns zero if the - UCN has not been consumed. + buffer end is delimited by a non-hex digit. Returns false if the + UCN has not been consumed, true otherwise. - Otherwise the nonzero value of the UCN, whether valid or invalid, - is returned. Diagnostics are emitted for invalid values. PSTR - is updated to point one beyond the UCN, or to the syntactically - invalid character. + The value of the UCN, whether valid or invalid, is returned in *CP. + Diagnostics are emitted for invalid values. PSTR is updated to point + one beyond the UCN, or to the syntactically invalid character. IDENTIFIER_POS is 0 when not in an identifier, 1 for the start of an identifier, or 2 otherwise. */ -cppchar_t +bool _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr, const uchar *limit, int identifier_pos, - struct normalize_state *nst) + struct normalize_state *nst, cppchar_t *cp) { cppchar_t result, c; unsigned int length; @@ -1030,8 +1029,11 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr, multiple tokens in identifiers, so we can't give a helpful error message in that case. */ if (length && identifier_pos) - return 0; - + { + *cp = 0; + return false; + } + *pstr = str; if (length) { @@ -1079,10 +1081,8 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr, (int) (str - base), base); } - if (result == 0) - result = 1; - - return result; + *cp = result; + return true; } /* Convert an UCN, pointed to by FROM, to UTF-8 encoding, then translate @@ -1100,7 +1100,7 @@ convert_ucn (cpp_reader *pfile, const uchar *from, const uchar *limit, struct normalize_state nst = INITIAL_NORMALIZE_STATE; from++; /* Skip u/U. */ - ucn = _cpp_valid_ucn (pfile, &from, limit, 0, &nst); + _cpp_valid_ucn (pfile, &from, limit, 0, &nst, &ucn); rval = one_cppchar_to_utf8 (ucn, &bufp, &bytesleft); if (rval) |