// 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 N2836: 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 not allowed in an identifier}} extern int \U0001F477; // expected-error {{expected identifier or '('}} extern int X\U0001F477; // expected-error {{character not allowed in an identifier}} extern int ๐Ÿ‘ท; // expected-error {{unexpected character }} \ // expected-warning {{declaration does not declare anything}} extern int X๐Ÿ‘ท; // expected-error {{character not allowed in an identifier}} extern int ๐Ÿ•; // expected-error {{unexpected character }} \ // expected-warning {{declaration does not declare anything}} extern int X๐Ÿ•; // expected-error {{character not allowed in an identifier}} extern int ๐Ÿ’€; // expected-error {{unexpected character }} \ // expected-warning {{declaration does not declare anything}} extern int X๐Ÿ’€; // expected-error {{character not allowed in an identifier}} extern int ๐Ÿ‘Š; // expected-error {{unexpected character }} \ // expected-warning {{declaration does not declare anything}} extern int X๐Ÿ‘Š; // expected-error {{character not allowed in an identifier}} extern int ๐Ÿš€; // expected-error {{unexpected character }} \ // expected-warning {{declaration does not declare anything}} extern int X๐Ÿš€; // expected-error {{character not allowed in an identifier}} extern int ๐Ÿ˜€; // expected-error {{unexpected character }} \ // expected-warning {{declaration does not declare anything}} extern int X๐Ÿ˜€; // expected-error {{character 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 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 in an identifier is a Clang extension}} extern int \u00B9; // expected-error {{expected identifier or '('}} extern int X\u00B9; // expected-warning {{mathematical notation character in an identifier is a Clang extension}} extern int ยฒ; // expected-error {{character not allowed at the start of an identifier}} \\ // expected-warning {{declaration does not declare anything}} extern int Xยฒ; // expected-warning {{mathematical notation character in an identifier is a Clang extension}} extern int \N{PARTIAL DIFFERENTIAL}; // expected-warning {{mathematical notation character in an identifier is a Clang extension}} extern int X\N{PARTIAL DIFFERENTIAL}; // expected-warning {{mathematical notation character in an identifier is a Clang extension}} extern int \u2207; // expected-warning {{mathematical notation character in an identifier is a Clang extension}} extern int X\u2207; // expected-warning {{mathematical notation character in an identifier is a Clang extension}} extern int โˆž; // expected-warning {{mathematical notation character in an identifier is a Clang extension}} extern int Xโˆž; // expected-warning {{mathematical notation character in an identifier is a Clang extension}}