xref: /minix3/external/bsd/llvm/dist/clang/test/Lexer/char-literal.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -Wfour-char-constants -fsyntax-only -verify %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc #ifndef __cplusplus
5*f4a2713aSLionel Sambuc typedef __WCHAR_TYPE__ wchar_t;
6*f4a2713aSLionel Sambuc typedef __CHAR16_TYPE__ char16_t;
7*f4a2713aSLionel Sambuc typedef __CHAR32_TYPE__ char32_t;
8*f4a2713aSLionel Sambuc #endif
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc int a = 'ab'; // expected-warning {{multi-character character constant}}
11*f4a2713aSLionel Sambuc int b = '\xFF\xFF'; // expected-warning {{multi-character character constant}}
12*f4a2713aSLionel Sambuc int c = 'APPS'; // expected-warning {{multi-character character constant}}
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc char d = '⌘'; // expected-error {{character too large for enclosing character literal type}}
15*f4a2713aSLionel Sambuc char e = '\u2318'; // expected-error {{character too large for enclosing character literal type}}
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc #ifdef __cplusplus
18*f4a2713aSLionel Sambuc auto f = '\xE2\x8C\x98'; // expected-warning {{multi-character character constant}}
19*f4a2713aSLionel Sambuc #endif
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
22*f4a2713aSLionel Sambuc char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}}
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
25*f4a2713aSLionel Sambuc wchar_t j = L'\U0010FFFD';
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc char32_t k = U'\U0010FFFD';
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc char l = 'Ø'; // expected-error {{character too large for enclosing character literal type}}
30*f4a2713aSLionel Sambuc char m = '��'; // expected-error {{character too large for enclosing character literal type}}
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
33*f4a2713aSLionel Sambuc char16_t o = '��'; // expected-error {{character too large for enclosing character literal type}}
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc char16_t p[2] = u"\U0000FFFF";
36*f4a2713aSLionel Sambuc char16_t q[2] = u"\U00010000";
37*f4a2713aSLionel Sambuc #ifdef __cplusplus
38*f4a2713aSLionel Sambuc // expected-error@-2 {{too long}}
39*f4a2713aSLionel Sambuc #endif
40