84 lines · c
1// RUN: %clang_cc1 -x c -std=c2x -fsyntax-only -verify %s2// RUN: %clang_cc1 -x c -std=c2x -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace3 4/* WG14 N2836: Clang 155 * Identifier Syntax using Unicode Standard Annex 316 */7 8/* WG14 N2939: Clang 159 * Identifier Syntax Fixes10 */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 © 201221#define XSTR(X) #X22#define STR(X) XSTR(X)23 24static const char *copyright = STR(COPYRIGHT); // no-warning25// CHECK: static const char *copyright = "Copyright © {{2012}}";26 27#if PP_ONLY28COPYRIGHT29// CHECK: Copyright © {{2012}}30#endif31 32// The characters in the following identifiers are no longer valid as either33// start or continuation characters as of C23. These are taken from section 134// of N2836.35extern int \N{CONSTRUCTION WORKER}; // expected-error {{expected identifier or '('}}36extern int X\N{CONSTRUCTION WORKER}; // expected-error {{character <U+1F477> not allowed in an identifier}}37extern int \U0001F477; // expected-error {{expected identifier or '('}}38extern int X\U0001F477; // expected-error {{character <U+1F477> not allowed in an identifier}}39extern int 👷; // expected-error {{unexpected character <U+1F477>}} \40 // expected-warning {{declaration does not declare anything}}41extern int X👷; // expected-error {{character <U+1F477> not allowed in an identifier}}42extern int 🕐; // expected-error {{unexpected character <U+1F550>}} \43 // expected-warning {{declaration does not declare anything}}44extern int X🕐; // expected-error {{character <U+1F550> not allowed in an identifier}}45extern int 💀; // expected-error {{unexpected character <U+1F480>}} \46 // expected-warning {{declaration does not declare anything}}47extern int X💀; // expected-error {{character <U+1F480> not allowed in an identifier}}48extern int 👊; // expected-error {{unexpected character <U+1F44A>}} \49 // expected-warning {{declaration does not declare anything}}50extern int X👊; // expected-error {{character <U+1F44A> not allowed in an identifier}}51extern int 🚀; // expected-error {{unexpected character <U+1F680>}} \52 // expected-warning {{declaration does not declare anything}}53extern int X🚀; // expected-error {{character <U+1F680> not allowed in an identifier}}54extern int 😀; // expected-error {{unexpected character <U+1F600>}} \55 // expected-warning {{declaration does not declare anything}}56extern int X😀; // expected-error {{character <U+1F600> not allowed in an identifier}}57 58// The characters in the following identifiers are not allowed as start59// characters, but are allowed as continuation characters.60extern int \N{ARABIC-INDIC DIGIT ZERO}; // expected-error {{expected identifier or '('}}61extern int X\N{ARABIC-INDIC DIGIT ZERO};62extern int \u0661; // expected-error {{expected identifier or '('}}63extern int X\u0661;64extern int ٢; // expected-error {{character <U+0662> not allowed at the start of an identifier}} \\65 // expected-warning {{declaration does not declare anything}}66extern int X٠;67 68// The characters in the following identifiers are not valid start or69// continuation characters in the standard, but are accepted as a conforming70// extension.71extern int \N{SUPERSCRIPT ZERO}; // expected-error {{expected identifier or '('}}72extern int X\N{SUPERSCRIPT ZERO}; // expected-warning {{mathematical notation character <U+2070> in an identifier is a Clang extension}}73extern int \u00B9; // expected-error {{expected identifier or '('}}74extern int X\u00B9; // expected-warning {{mathematical notation character <U+00B9> in an identifier is a Clang extension}}75extern int ²; // expected-error {{character <U+00B2> not allowed at the start of an identifier}} \\76 // expected-warning {{declaration does not declare anything}}77extern int X²; // expected-warning {{mathematical notation character <U+00B2> in an identifier is a Clang extension}}78extern int \N{PARTIAL DIFFERENTIAL}; // expected-warning {{mathematical notation character <U+2202> in an identifier is a Clang extension}}79extern int X\N{PARTIAL DIFFERENTIAL}; // expected-warning {{mathematical notation character <U+2202> in an identifier is a Clang extension}}80extern int \u2207; // expected-warning {{mathematical notation character <U+2207> in an identifier is a Clang extension}}81extern int X\u2207; // expected-warning {{mathematical notation character <U+2207> in an identifier is a Clang extension}}82extern int ∞; // expected-warning {{mathematical notation character <U+221E> in an identifier is a Clang extension}}83extern int X∞; // expected-warning {{mathematical notation character <U+221E> in an identifier is a Clang extension}}84