aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2005-03-16 00:59:31 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2005-03-16 00:59:31 +0000
commitc79e602b6302889036c04a7ca530afc5ae97e053 (patch)
tree62dc23023bb72619d67f7423a9526121e5f67962 /libcpp
parent2532808d17ab69f24bb50e9daf6c27e20d90f352 (diff)
downloadgcc-c79e602b6302889036c04a7ca530afc5ae97e053.zip
gcc-c79e602b6302889036c04a7ca530afc5ae97e053.tar.gz
gcc-c79e602b6302889036c04a7ca530afc5ae97e053.tar.bz2
charset.c (_cpp_valid_ucn): In identifiers, reject a partial UCN rather than printing an error.
2005-03-15 Geoffrey Keating <geoffk@apple.com> * charset.c (_cpp_valid_ucn): In identifiers, reject a partial UCN rather than printing an error. Index: gcc/testsuite/ChangeLog 2005-03-15 Geoffrey Keating <geoffk@apple.com> * gcc.dg/cpp/ucnid-7.c: New. From-SVN: r96546
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog5
-rw-r--r--libcpp/charset.c12
2 files changed, 13 insertions, 4 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 043acee..e5ecf6d 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-15 Geoffrey Keating <geoffk@apple.com>
+
+ * charset.c (_cpp_valid_ucn): In identifiers, reject a partial
+ UCN rather than printing an error.
+
2005-03-14 Geoffrey Keating <geoffk@apple.com>
* lex.c (forms_identifier_p): Disable UCNs in C89 mode.
diff --git a/libcpp/charset.c b/libcpp/charset.c
index f028b37..ba53f63 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -923,9 +923,8 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c,
program is ill-formed.
*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 UCNs
- are not part of the relevant standard, or if the string beginning
- at *PSTR doesn't syntactically match the form 'NNNN' or 'NNNNNNNN'.
+ buffer end is delimited by a non-hex digit. Returns zero if the
+ UCN has not been consumed.
Otherwise the nonzero value of the UCN, whether valid or invalid,
is returned. Diagnostics are emitted for invalid values. PSTR
@@ -974,10 +973,15 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
}
while (--length && str < limit);
+ /* Partial UCNs are not valid in strings, but decompose into
+ multiple tokens in identifiers, so we can't give a helpful
+ error message in that case. */
+ if (length && identifier_pos)
+ return 0;
+
*pstr = str;
if (length)
{
- /* We'll error when we try it out as the start of an identifier. */
cpp_error (pfile, CPP_DL_ERROR,
"incomplete universal character name %.*s",
(int) (str - base), base);