xref: /minix3/external/bsd/llvm/dist/clang/test/Preprocessor/ucn-allowed-chars.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -std=c99 -verify
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -std=c11 -Wc99-compat -verify
3f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++03 -Wc++11-compat -verify
4f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++11 -Wc++98-compat -verify
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc // Identifier characters
7f4a2713aSLionel Sambuc extern char a\u01F6; // C11, C++11
8f4a2713aSLionel Sambuc extern char a\u00AA; // C99, C11, C++11
9f4a2713aSLionel Sambuc extern char a\u0384; // C++03, C11, C++11
10f4a2713aSLionel Sambuc extern char a\u0E50; // C99, C++03, C11, C++11
11f4a2713aSLionel Sambuc extern char a\uFFFF; // none
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc // Identifier initial characters
18f4a2713aSLionel Sambuc extern char \u0E50; // C++03, C11, C++11
19f4a2713aSLionel Sambuc extern char \u0300; // disallowed initially in C11/C++11, always in C99/C++03
20*0a6a1f1dSLionel Sambuc extern char \u0D61; // C99, C11, C++03, C++11
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc // Disallowed everywhere
29f4a2713aSLionel Sambuc #define A \u0000 // expected-error{{control character}}
30f4a2713aSLionel Sambuc #define B \u001F // expected-error{{control character}}
31f4a2713aSLionel Sambuc #define C \u007F // expected-error{{control character}}
32f4a2713aSLionel Sambuc #define D \u009F // expected-error{{control character}}
33f4a2713aSLionel Sambuc #define E \uD800 // C++03 allows UCNs representing surrogate characters!
34f4a2713aSLionel Sambuc 
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc 
37f4a2713aSLionel Sambuc 
38f4a2713aSLionel Sambuc 
39f4a2713aSLionel Sambuc 
40f4a2713aSLionel Sambuc #if __cplusplus
41f4a2713aSLionel Sambuc # if __cplusplus >= 201103L
42f4a2713aSLionel Sambuc // C++11
43f4a2713aSLionel Sambuc // expected-warning@7 {{using this character in an identifier is incompatible with C++98}}
44f4a2713aSLionel Sambuc // expected-warning@8 {{using this character in an identifier is incompatible with C++98}}
45f4a2713aSLionel Sambuc // expected-error@11 {{expected ';'}}
46f4a2713aSLionel Sambuc // expected-error@19 {{expected unqualified-id}}
47f4a2713aSLionel Sambuc // expected-error@33 {{invalid universal character}}
48f4a2713aSLionel Sambuc 
49f4a2713aSLionel Sambuc # else
50f4a2713aSLionel Sambuc // C++03
51f4a2713aSLionel Sambuc // expected-error@7 {{expected ';'}}
52f4a2713aSLionel Sambuc // expected-error@8 {{expected ';'}}
53f4a2713aSLionel Sambuc // expected-error@11 {{expected ';'}}
54f4a2713aSLionel Sambuc // expected-error@19 {{expected unqualified-id}}
55f4a2713aSLionel Sambuc // expected-warning@33 {{universal character name refers to a surrogate character}}
56f4a2713aSLionel Sambuc 
57f4a2713aSLionel Sambuc # endif
58f4a2713aSLionel Sambuc #else
59f4a2713aSLionel Sambuc # if __STDC_VERSION__ >= 201112L
60f4a2713aSLionel Sambuc // C11
61f4a2713aSLionel Sambuc // expected-warning@7 {{using this character in an identifier is incompatible with C99}}
62f4a2713aSLionel Sambuc // expected-warning@9 {{using this character in an identifier is incompatible with C99}}
63f4a2713aSLionel Sambuc // expected-error@11 {{expected ';'}}
64f4a2713aSLionel Sambuc // expected-warning@18 {{starting an identifier with this character is incompatible with C99}}
65f4a2713aSLionel Sambuc // expected-error@19 {{expected identifier}}
66f4a2713aSLionel Sambuc // expected-error@33 {{invalid universal character}}
67f4a2713aSLionel Sambuc 
68f4a2713aSLionel Sambuc # else
69f4a2713aSLionel Sambuc // C99
70f4a2713aSLionel Sambuc // expected-error@7 {{expected ';'}}
71f4a2713aSLionel Sambuc // expected-error@9 {{expected ';'}}
72f4a2713aSLionel Sambuc // expected-error@11 {{expected ';'}}
73f4a2713aSLionel Sambuc // expected-error@18 {{expected identifier}}
74f4a2713aSLionel Sambuc // expected-error@19 {{expected identifier}}
75f4a2713aSLionel Sambuc // expected-error@33 {{invalid universal character}}
76f4a2713aSLionel Sambuc 
77f4a2713aSLionel Sambuc # endif
78f4a2713aSLionel Sambuc #endif
79