Skip to content

Commit 53b4689

Browse files
authored
[Clang] Mark WG14 N2939 (Identifier Syntax Fixes) as available in Clang 15 (#74666)
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.
1 parent 0113722 commit 53b4689

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

clang/test/C/C2x/n2836_n2939.c

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// RUN: %clang_cc1 -x c -std=c2x -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -x c -std=c2x -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
3+
4+
/* WG14 N2836: Clang 15
5+
* Identifier Syntax using Unicode Standard Annex 31
6+
*/
7+
8+
/* WG14 N2939: Clang 15
9+
* Identifier Syntax Fixes
10+
*/
11+
12+
// Some of the tests below are derived from clang/test/Lexer/unicode.c.
13+
14+
// This file contains Unicode characters; please do not "fix" them!
15+
16+
// No diagnostics for pragma directives.
17+
#pragma mark ¡Unicode!
18+
19+
// lone non-identifier characters are allowed in preprocessing.
20+
#define COPYRIGHT Copyright © 2012
21+
#define XSTR(X) #X
22+
#define STR(X) XSTR(X)
23+
24+
static const char *copyright = STR(COPYRIGHT); // no-warning
25+
// CHECK: static const char *copyright = "Copyright © {{2012}}";
26+
27+
#if PP_ONLY
28+
COPYRIGHT
29+
// CHECK: Copyright © {{2012}}
30+
#endif
31+
32+
// The characters in the following identifiers are no longer valid as either
33+
// start or continuation characters as of C23. These are taken from section 1
34+
// of N2836.
35+
extern int \N{CONSTRUCTION WORKER}; // expected-error {{expected identifier or '('}}
36+
extern int X\N{CONSTRUCTION WORKER}; // expected-error {{character <U+1F477> not allowed in an identifier}}
37+
extern int \U0001F477; // expected-error {{expected identifier or '('}}
38+
extern int X\U0001F477; // expected-error {{character <U+1F477> not allowed in an identifier}}
39+
extern int 👷; // expected-error {{unexpected character <U+1F477>}} \
40+
// expected-warning {{declaration does not declare anything}}
41+
extern int X👷; // expected-error {{character <U+1F477> not allowed in an identifier}}
42+
extern int 🕐; // expected-error {{unexpected character <U+1F550>}} \
43+
// expected-warning {{declaration does not declare anything}}
44+
extern int X🕐; // expected-error {{character <U+1F550> not allowed in an identifier}}
45+
extern int 💀; // expected-error {{unexpected character <U+1F480>}} \
46+
// expected-warning {{declaration does not declare anything}}
47+
extern int X💀; // expected-error {{character <U+1F480> not allowed in an identifier}}
48+
extern int 👊; // expected-error {{unexpected character <U+1F44A>}} \
49+
// expected-warning {{declaration does not declare anything}}
50+
extern int X👊; // expected-error {{character <U+1F44A> not allowed in an identifier}}
51+
extern int 🚀; // expected-error {{unexpected character <U+1F680>}} \
52+
// expected-warning {{declaration does not declare anything}}
53+
extern int X🚀; // expected-error {{character <U+1F680> not allowed in an identifier}}
54+
extern int 😀; // expected-error {{unexpected character <U+1F600>}} \
55+
// expected-warning {{declaration does not declare anything}}
56+
extern int X😀; // expected-error {{character <U+1F600> not allowed in an identifier}}
57+
58+
// The characters in the following identifiers are not allowed as start
59+
// characters, but are allowed as continuation characters.
60+
extern int \N{ARABIC-INDIC DIGIT ZERO}; // expected-error {{expected identifier or '('}}
61+
extern int X\N{ARABIC-INDIC DIGIT ZERO};
62+
extern int \u0661; // expected-error {{expected identifier or '('}}
63+
extern int X\u0661;
64+
extern int ٢; // expected-error {{character <U+0662> not allowed at the start of an identifier}} \\
65+
// expected-warning {{declaration does not declare anything}}
66+
extern int ;
67+
68+
// The characters in the following identifiers are not valid start or
69+
// continuation characters in the standard, but are accepted as a conforming
70+
// extension.
71+
extern int \N{SUPERSCRIPT ZERO}; // expected-error {{expected identifier or '('}}
72+
extern int X\N{SUPERSCRIPT ZERO}; // expected-warning {{mathematical notation character <U+2070> in an identifier is a Clang extension}}
73+
extern int \u00B9; // expected-error {{expected identifier or '('}}
74+
extern int X\u00B9; // expected-warning {{mathematical notation character <U+00B9> in an identifier is a Clang extension}}
75+
extern int ²; // expected-error {{character <U+00B2> not allowed at the start of an identifier}} \\
76+
// expected-warning {{declaration does not declare anything}}
77+
extern int X²; // expected-warning {{mathematical notation character <U+00B2> in an identifier is a Clang extension}}
78+
extern int \N{PARTIAL DIFFERENTIAL}; // expected-warning {{mathematical notation character <U+2202> in an identifier is a Clang extension}}
79+
extern int X\N{PARTIAL DIFFERENTIAL}; // expected-warning {{mathematical notation character <U+2202> in an identifier is a Clang extension}}
80+
extern int \u2207; // expected-warning {{mathematical notation character <U+2207> in an identifier is a Clang extension}}
81+
extern int X\u2207; // expected-warning {{mathematical notation character <U+2207> in an identifier is a Clang extension}}
82+
extern int ∞; // expected-warning {{mathematical notation character <U+221E> in an identifier is a Clang extension}}
83+
extern int X∞; // expected-warning {{mathematical notation character <U+221E> in an identifier is a Clang extension}}

clang/www/c_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ <h2 id="c2x">C23 implementation status</h2>
11511151
<tr>
11521152
<td>Identifier syntax fixes</td>
11531153
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2939.pdf">N2939</a></td>
1154-
<td class="unknown" align="center">Unknown</td>
1154+
<td class="full" align="center">Clang 15</td>
11551155
</tr>
11561156
<tr>
11571157
<td>Remove trigraphs??!</td>

0 commit comments

Comments
 (0)