[clang] [Clang] Mark WG14 N2939 (Identifier Syntax Fixes) as available in Clang 15 (PR #74666)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 08:46:06 PST 2023


https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/74666

>From fd5728ed346c097577d58c4c20dfc696f9b17740 Mon Sep 17 00:00:00 2001
From: Tom Honermann <tom.honermann at intel.com>
Date: Wed, 6 Dec 2023 14:27:25 -0800
Subject: [PATCH 1/2] [Clang] Mark WG14 N2939 (Identifier Syntax Fixes) as
 available in Clang 15

WG14 N2939 (Identifier Syntax Fixes) corrects a grammar issue in the C
standard but does not otherwise change intended behavior. This change
updates the C23 status to note this paper as implemented as of Clang 15;
the release in which support for N2836 (Identifier Syntax using Unicode
Standard Annex 31) was implemented.
---
 clang/test/C/C2x/n2836_n2939.c | 83 ++++++++++++++++++++++++++++++++++
 clang/www/c_status.html        |  2 +-
 2 files changed, 84 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/C/C2x/n2836_n2939.c

diff --git a/clang/test/C/C2x/n2836_n2939.c b/clang/test/C/C2x/n2836_n2939.c
new file mode 100644
index 0000000000000..14095aa53456b
--- /dev/null
+++ b/clang/test/C/C2x/n2836_n2939.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -x c -std=c2x -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -std=c2x -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
+
+/* WG14 N2863: Clang 15
+ *   Identifier Syntax using Unicode Standard Annex 31
+ */
+
+/* WG14 N2939: Clang 15
+ *   Identifier Syntax Fixes
+ */
+
+// Some of the tests below are derived from clang/test/Lexer/unicode.c.
+
+// This file contains Unicode characters; please do not "fix" them!
+
+// No diagnostics for pragma directives.
+#pragma mark ยกUnicode!
+
+// lone non-identifier characters are allowed in preprocessing.
+#define COPYRIGHT Copyright ยฉ 2012
+#define XSTR(X) #X
+#define STR(X) XSTR(X)
+
+static const char *copyright = STR(COPYRIGHT); // no-warning
+// CHECK: static const char *copyright = "Copyright ยฉ {{2012}}";
+
+#if PP_ONLY
+COPYRIGHT
+// CHECK: Copyright ยฉ {{2012}}
+#endif
+
+// The characters in the following identifiers are no longer valid as either
+// start or continuation characters as of C23. These are taken from section 1
+// of N2836.
+extern int \N{CONSTRUCTION WORKER};  // expected-error {{expected identifier or '('}}
+extern int X\N{CONSTRUCTION WORKER}; // expected-error {{character <U+1F477> not allowed in an identifier}}
+extern int \U0001F477;  // expected-error {{expected identifier or '('}}
+extern int X\U0001F477; // expected-error {{character <U+1F477> not allowed in an identifier}}
+extern int ๐Ÿ‘ท;  // expected-error {{unexpected character <U+1F477>}} \
+                // expected-warning {{declaration does not declare anything}}
+extern int X๐Ÿ‘ท; // expected-error {{character <U+1F477> not allowed in an identifier}}
+extern int ๐Ÿ•;  // expected-error {{unexpected character <U+1F550>}} \
+                // expected-warning {{declaration does not declare anything}}
+extern int X๐Ÿ•; // expected-error {{character <U+1F550> not allowed in an identifier}}
+extern int ๐Ÿ’€;  // expected-error {{unexpected character <U+1F480>}} \
+                // expected-warning {{declaration does not declare anything}}
+extern int X๐Ÿ’€; // expected-error {{character <U+1F480> not allowed in an identifier}}
+extern int ๐Ÿ‘Š;  // expected-error {{unexpected character <U+1F44A>}} \
+                // expected-warning {{declaration does not declare anything}}
+extern int X๐Ÿ‘Š; // expected-error {{character <U+1F44A> not allowed in an identifier}}
+extern int ๐Ÿš€;  // expected-error {{unexpected character <U+1F680>}} \
+                // expected-warning {{declaration does not declare anything}}
+extern int X๐Ÿš€; // expected-error {{character <U+1F680> not allowed in an identifier}}
+extern int ๐Ÿ˜€;  // expected-error {{unexpected character <U+1F600>}} \
+                // expected-warning {{declaration does not declare anything}}
+extern int X๐Ÿ˜€; // expected-error {{character <U+1F600> not allowed in an identifier}}
+
+// The characters in the following identifiers are not allowed as start
+// characters, but are allowed as continuation characters.
+extern int \N{ARABIC-INDIC DIGIT ZERO}; // expected-error {{expected identifier or '('}}
+extern int X\N{ARABIC-INDIC DIGIT ZERO};
+extern int \u0661; // expected-error {{expected identifier or '('}}
+extern int X\u0661;
+extern int ูข;  // expected-error {{character <U+0662> not allowed at the start of an identifier}} \\
+               // expected-warning {{declaration does not declare anything}}
+extern int Xู ;
+
+// The characters in the following identifiers are not valid start or
+// continuation characters in the standard, but are accepted as a conforming
+// extension.
+extern int \N{SUPERSCRIPT ZERO};  // expected-error {{expected identifier or '('}}
+extern int X\N{SUPERSCRIPT ZERO}; // expected-warning {{mathematical notation character <U+2070> in an identifier is a Clang extension}}
+extern int \u00B9;  // expected-error {{expected identifier or '('}}
+extern int X\u00B9; // expected-warning {{mathematical notation character <U+00B9> in an identifier is a Clang extension}}
+extern int ยฒ;  // expected-error {{character <U+00B2> not allowed at the start of an identifier}} \\
+               // expected-warning {{declaration does not declare anything}}
+extern int Xยฒ; // expected-warning {{mathematical notation character <U+00B2> in an identifier is a Clang extension}}
+extern int \N{PARTIAL DIFFERENTIAL};  // expected-warning {{mathematical notation character <U+2202> in an identifier is a Clang extension}}
+extern int X\N{PARTIAL DIFFERENTIAL}; // expected-warning {{mathematical notation character <U+2202> in an identifier is a Clang extension}}
+extern int \u2207;  // expected-warning {{mathematical notation character <U+2207> in an identifier is a Clang extension}}
+extern int X\u2207; // expected-warning {{mathematical notation character <U+2207> in an identifier is a Clang extension}}
+extern int โˆž;  // expected-warning {{mathematical notation character <U+221E> in an identifier is a Clang extension}}
+extern int Xโˆž; // expected-warning {{mathematical notation character <U+221E> in an identifier is a Clang extension}}
diff --git a/clang/www/c_status.html b/clang/www/c_status.html
index 91cae138074b3..47acb1f87b8e3 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -1151,7 +1151,7 @@ <h2 id="c2x">C23 implementation status</h2>
     <tr>
       <td>Identifier syntax fixes</td>
       <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2939.pdf">N2939</a></td>
-      <td class="unknown" align="center">Unknown</td>
+      <td class="full" align="center">Clang 15</td>
     </tr>
     <tr>
       <td>Remove trigraphs??!</td>

>From 94579817e41448e151edf16bca0076fa8ce32edc Mon Sep 17 00:00:00 2001
From: Tom Honermann <tom.honermann at intel.com>
Date: Thu, 7 Dec 2023 08:45:45 -0800
Subject: [PATCH 2/2] Squash.

---
 clang/test/C/C2x/n2836_n2939.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/C/C2x/n2836_n2939.c b/clang/test/C/C2x/n2836_n2939.c
index 14095aa53456b..13e23c3def80d 100644
--- a/clang/test/C/C2x/n2836_n2939.c
+++ b/clang/test/C/C2x/n2836_n2939.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -x c -std=c2x -fsyntax-only -verify %s
 // RUN: %clang_cc1 -x c -std=c2x -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
 
-/* WG14 N2863: Clang 15
+/* WG14 N2836: Clang 15
  *   Identifier Syntax using Unicode Standard Annex 31
  */
 



More information about the cfe-commits mailing list