charset.c (_cpp_valid_ucn): In identifiers, reject a partial UCN rather than printing...
authorGeoffrey Keating <geoffk@apple.com>
Wed, 16 Mar 2005 00:59:31 +0000 (00:59 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Wed, 16 Mar 2005 00:59:31 +0000 (00:59 +0000)
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

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/ucnid-7.c [new file with mode: 0644]
libcpp/ChangeLog
libcpp/charset.c

index fd4e902b50da70139fe0ea110d8ae7309bdbdb99..9f4d667f69f3502d7c1949cb178c44a786f08486 100644 (file)
@@ -1,3 +1,7 @@
+2005-03-15  Geoffrey Keating  <geoffk@apple.com>
+
+       * gcc.dg/cpp/ucnid-7.c: New.
+
 2005-03-15  Janis Johnson  <janis187@us.ibm.com>
            Dorit Naishlos  <dorit@il.ibm.com>
 
diff --git a/gcc/testsuite/gcc.dg/cpp/ucnid-7.c b/gcc/testsuite/gcc.dg/cpp/ucnid-7.c
new file mode 100644 (file)
index 0000000..854c948
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c99" } */
+#define a b(
+#define b(x) q
+int a\U0000000z );
index 043aceed71a818cef3373f482a63f4a67f8ed97c..e5ecf6d3d0063f14d8a235ee8a35c22e95db17e1 100644 (file)
@@ -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.
index f028b371440bdbdb58296e31d3833b0926a0ecc0..ba53f6337ccd263e34fdd5b28ae68fbd90757561 100644 (file)
@@ -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);