1 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
3 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx -x c++ -std=c++11 %s
4 // RUN: %clang_cc1 -std=c99 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
5 // RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
7 // This file contains Unicode characters; please do not "fix" them!
9 extern int x
; // expected-warning {{treating Unicode character as whitespace}}
10 extern int x
; // expected-warning {{treating Unicode character as whitespace}}
12 // CHECK: extern int {{x}}
13 // CHECK: extern int {{x}}
15 #pragma mark ¡Unicode!
17 #define COPYRIGHT Copyright © 2012
19 #define STR(X) XSTR(X)
21 static const char *copyright
= STR(COPYRIGHT
); // no-warning
22 // CHECK: static const char *copyright = "Copyright © {{2012}}";
26 // CHECK: Copyright © {{2012}}
27 CHECK
: The preprocessor should
not complain about Unicode characters like ©
.
32 extern int X\UAAAAAAAA
; // expected-error {{not allowed in an identifier}}
33 int Y
= '\UAAAAAAAA'; // expected-error {{invalid universal character}}
35 #if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
41 extern int \u1B4C; // BALINESE LETTER ARCHAIC JNYA - Added in Unicode 14
42 extern int \U00016AA2
; // TANGSA LETTER GA - Added in Unicode 14
43 extern int \U0001E4D0
; // 𞓐 NAG MUNDARI LETTER O - Added in Unicode 15
44 extern int a\N
{TANGSA LETTER GA
};
45 extern int a\N
{TANGSALETTERGA
}; // expected-error {{'TANGSALETTERGA' is not a valid Unicode character name}} \
46 // expected-error {{expected ';' after top level declarator}} \
47 // expected-note {{characters names in Unicode escape sequences are sensitive to case and whitespace}}
49 extern int 𝛛
; // expected-warning {{mathematical notation character <U+1D6DB> in an identifier is a Clang extension}}
50 extern int ₉
; // expected-error {{character <U+2089> not allowed at the start of an identifier}} \\
51 expected
-warning
{{declaration does
not declare anything
}}
53 int a¹b₍₄₂₎∇
; // expected-warning 6{{mathematical notation character}}
55 int \u
{221E
} = 1; // expected-warning {{mathematical notation character}}
56 int \N
{MATHEMATICAL SANS
-SERIF BOLD ITALIC PARTIAL DIFFERENTIAL
} = 1;
57 // expected-warning@-1 {{mathematical notation character}}
59 int a\N
{SUBSCRIPT EQUALS SIGN
} = 1; // expected-warning {{mathematical notation character}}
61 // This character doesn't have the XID_Start property
62 extern int \U00016AC0
; // TANGSA DIGIT ZERO // cxx-error {{expected unqualified-id}} \
63 // c2x-error {{expected identifier or '('}}
65 extern int 🌹
; // expected-error {{unexpected character <U+1F339>}} \
66 expected
-warning
{{declaration does
not declare anything
}}
68 extern int 🫎
; // MOOSE (Unicode 15) \
69 // expected-error {{unexpected character <U+1FACE>}} \
70 expected
-warning
{{declaration does
not declare anything
}}
72 extern int 👷
; // expected-error {{unexpected character <U+1F477>}} \
73 expected
-warning
{{declaration does
not declare anything
}}
75 extern int 👷♀
; // expected-warning {{declaration does not declare anything}} \
76 expected
-error
{{unexpected character
<U
+1F477
>}} \
77 expected
-error
{{unexpected character
<U
+200D
>}} \
78 expected
-error
{{unexpected character
<U
+2640>}}
81 // A 🌹 by any other name....
83 int 🌵
(int 🌻
) { return 🌻
+ 1; }
89 int n;
= 3; // expected-warning {{treating Unicode character <U+037E> as an identifier character rather than as ';' symbol}}
90 int *n꞉꞉v
= &n;
; // expected-warning 2{{treating Unicode character <U+A789> as an identifier character rather than as ':' symbol}}
91 // expected-warning@-1 {{treating Unicode character <U+037E> as an identifier character rather than as ';' symbol}}
92 int v=[=](
auto){
return~x;}()
; // expected-warning 12{{treating Unicode character}}
95 // expected-warning@-1 {{identifier contains Unicode character <U+2060> that is invisible in some environments}}
96 // expected-warning@-2 {{identifier contains Unicode character <U+FEFF> that is invisible in some environments}}
97 // expected-warning@-3 {{identifier contains Unicode character <U+200D> that is invisible in some environments}}
98 int foobar
= 0; // expected-warning {{identifier contains Unicode character <U+200B> that is invisible in some environments}}
99 int x
= foobar
; // expected-error {{undeclared identifier}}
101 int ∣foo
; // expected-error {{unexpected character <U+2223>}}
103 #define ∶ x // expected-error {{macro name must be an identifier}}