1 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
3 // RUN: %clang_cc1 -std=c99 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
4 // RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
5 
6 // This file contains Unicode characters; please do not "fix" them!
7 
8 extern int x; // expected-warning {{treating Unicode character as whitespace}}
9 extern int x; // expected-warning {{treating Unicode character as whitespace}}
10 
11 // CHECK: extern int {{x}}
12 // CHECK: extern int {{x}}
13 
14 #pragma mark ¡Unicode!
15 
16 #define COPYRIGHT Copyright © 2012
17 #define XSTR(X) #X
18 #define STR(X) XSTR(X)
19 
20 static const char *copyright = STR(COPYRIGHT); // no-warning
21 // CHECK: static const char *copyright = "Copyright © {{2012}}";
22 
23 #if PP_ONLY
24 COPYRIGHT
25 // CHECK: Copyright © {{2012}}
26 CHECK : The preprocessor should not complain about Unicode characters like ©.
27 #endif
28 
29         int _;
30 
31 extern int X\UAAAAAAAA; // expected-error {{not allowed in an identifier}}
32 int Y = '\UAAAAAAAA'; // expected-error {{invalid universal character}}
33 
34 #ifdef __cplusplus
35 
36 extern int ༀ;
37 extern int ��;
38 extern int ��;
39 extern int ꙮ;
40 extern int  \u1B4C;     // BALINESE LETTER ARCHAIC JNYA - Added in Unicode 14
41 extern int  \U00016AA2; // TANGSA LETTER GA - Added in Unicode 14
42 extern int _\N{TANGSA LETTER GA};
43 extern int _\N{TANGSALETTERGA}; // expected-error {{'TANGSALETTERGA' is not a valid Unicode character name}} \
44                                 // expected-note {{characters names in Unicode escape sequences are sensitive to case and whitespace}}
45 
46 
47 
48 // This character doesn't have the XID_Start property
49 extern int  \U00016AC0; // TANGSA DIGIT ZERO  // expected-error {{expected unqualified-id}}
50 
51 extern int ��; // expected-error {{unexpected character <U+1F339>}} \
52                   expected-warning {{declaration does not declare anything}}
53 
54 extern int ��; // expected-error {{unexpected character <U+1F477>}} \
55                   expected-warning {{declaration does not declare anything}}
56 
57 extern int ��‍♀; // expected-warning {{declaration does not declare anything}} \
58                   expected-error {{unexpected character <U+1F477>}} \
59                   expected-error {{unexpected character <U+200D>}} \
60                   expected-error {{unexpected character <U+2640>}}
61 #else
62 
63 // A �� by any other name....
64 extern int ��;
65 int ��(int ��) { return ��+ 1; }
66 int main (void) {
67   int �� = ��(��);
68   return ��;
69 }
70 
71 int n; = 3; // expected-warning {{treating Unicode character <U+037E> as identifier character rather than as ';' symbol}}
72 int *n꞉꞉v = &n;; // expected-warning 2{{treating Unicode character <U+A789> as identifier character rather than as ':' symbol}}
73                  // expected-warning@-1 {{treating Unicode character <U+037E> as identifier character rather than as ';' symbol}}
74 int v=[=](auto){return~x;}(); // expected-warning 12{{treating Unicode character}}
75 
76 int ⁠xx‍;
77 // expected-warning@-1 {{identifier contains Unicode character <U+2060> that is invisible in some environments}}
78 // expected-warning@-2 {{identifier contains Unicode character <U+FEFF> that is invisible in some environments}}
79 // expected-warning@-3 {{identifier contains Unicode character <U+200D> that is invisible in some environments}}
80 int foo​bar = 0; // expected-warning {{identifier contains Unicode character <U+200B> that is invisible in some environments}}
81 int x = foobar; // expected-error {{undeclared identifier}}
82 
83 int ∣foo; // expected-error {{unexpected character <U+2223>}}
84 #ifndef PP_ONLY
85 #define ∶ x // expected-error {{macro name must be an identifier}}
86 #endif
87 
88 #endif
89