xref: /aosp_15_r20/external/clang/test/Preprocessor/utf8-allowed-chars.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -fsyntax-only -std=c99 -verify
2*67e74705SXin Li // RUN: %clang_cc1 %s -fsyntax-only -std=c11 -Wc99-compat -verify
3*67e74705SXin Li // RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++03 -Wc++11-compat -verify
4*67e74705SXin Li // RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++11 -Wc++98-compat -verify
5*67e74705SXin Li 
6*67e74705SXin Li // Note: This file contains Unicode characters; please do not remove them!
7*67e74705SXin Li 
8*67e74705SXin Li // Identifier characters
9*67e74705SXin Li extern char aǶ; // C11, C++11
10*67e74705SXin Li extern char aª; // C99, C11, C++11
11*67e74705SXin Li extern char a΄; // C++03, C11, C++11
12*67e74705SXin Li extern char a๐; // C99, C++03, C11, C++11
13*67e74705SXin Li extern char a﹅; // none
14*67e74705SXin Li extern char x̀; // C11, C++11. Note that this does not have a composed form.
15*67e74705SXin Li 
16*67e74705SXin Li 
17*67e74705SXin Li 
18*67e74705SXin Li 
19*67e74705SXin Li // Identifier initial characters
20*67e74705SXin Li extern char ๐; // C++03, C11, C++11
21*67e74705SXin Li extern char ̀; // disallowed initially in C11/C++11, always in C99/C++03
22*67e74705SXin Li 
23*67e74705SXin Li 
24*67e74705SXin Li 
25*67e74705SXin Li 
26*67e74705SXin Li 
27*67e74705SXin Li 
28*67e74705SXin Li 
29*67e74705SXin Li 
30*67e74705SXin Li #if __cplusplus
31*67e74705SXin Li # if __cplusplus >= 201103L
32*67e74705SXin Li // C++11
33*67e74705SXin Li // expected-warning@9 {{using this character in an identifier is incompatible with C++98}}
34*67e74705SXin Li // expected-warning@10 {{using this character in an identifier is incompatible with C++98}}
35*67e74705SXin Li // expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
36*67e74705SXin Li // expected-warning@14 {{using this character in an identifier is incompatible with C++98}}
37*67e74705SXin Li // expected-error@21 {{expected unqualified-id}}
38*67e74705SXin Li 
39*67e74705SXin Li # else
40*67e74705SXin Li // C++03
41*67e74705SXin Li // expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
42*67e74705SXin Li // expected-error@10 {{non-ASCII characters are not allowed outside of literals and identifiers}}
43*67e74705SXin Li // expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
44*67e74705SXin Li // expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
45*67e74705SXin Li // expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
46*67e74705SXin Li 
47*67e74705SXin Li # endif
48*67e74705SXin Li #else
49*67e74705SXin Li # if __STDC_VERSION__ >= 201112L
50*67e74705SXin Li // C11
51*67e74705SXin Li // expected-warning@9 {{using this character in an identifier is incompatible with C99}}
52*67e74705SXin Li // expected-warning@11 {{using this character in an identifier is incompatible with C99}}
53*67e74705SXin Li // expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
54*67e74705SXin Li // expected-warning@14 {{using this character in an identifier is incompatible with C99}}
55*67e74705SXin Li // expected-warning@20 {{starting an identifier with this character is incompatible with C99}}
56*67e74705SXin Li // expected-error@21 {{expected identifier}}
57*67e74705SXin Li 
58*67e74705SXin Li # else
59*67e74705SXin Li // C99
60*67e74705SXin Li // expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
61*67e74705SXin Li // expected-error@11 {{non-ASCII characters are not allowed outside of literals and identifiers}}
62*67e74705SXin Li // expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
63*67e74705SXin Li // expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
64*67e74705SXin Li // expected-error@20 {{expected identifier}}
65*67e74705SXin Li // expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
66*67e74705SXin Li 
67*67e74705SXin Li # endif
68*67e74705SXin Li #endif
69