blob: 1cd14a9b0116724525b10a8562c0f30d04ddf8c2 [file] [log] [blame]
Seth Cantrell7748cbc2012-01-18 12:27:10 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s
Richard Smith0093e122013-03-09 23:56:02 +00002// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -Wfour-char-constants -fsyntax-only -verify %s
3
4#ifndef __cplusplus
5typedef __WCHAR_TYPE__ wchar_t;
6typedef __CHAR16_TYPE__ char16_t;
7typedef __CHAR32_TYPE__ char32_t;
8#endif
Seth Cantrell7748cbc2012-01-18 12:27:10 +00009
10int a = 'ab'; // expected-warning {{multi-character character constant}}
11int b = '\xFF\xFF'; // expected-warning {{multi-character character constant}}
12int c = 'APPS'; // expected-warning {{multi-character character constant}}
13
14char d = '⌘'; // expected-error {{character too large for enclosing character literal type}}
15char e = '\u2318'; // expected-error {{character too large for enclosing character literal type}}
16
Richard Smith0093e122013-03-09 23:56:02 +000017#ifdef __cplusplus
Seth Cantrell7748cbc2012-01-18 12:27:10 +000018auto f = '\xE2\x8C\x98'; // expected-warning {{multi-character character constant}}
Richard Smith0093e122013-03-09 23:56:02 +000019#endif
Seth Cantrell7748cbc2012-01-18 12:27:10 +000020
21char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
22char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}}
23
24wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
25wchar_t j = L'\U0010FFFD';
26
27char32_t k = U'\U0010FFFD';
28
29char l = 'Ø'; // expected-error {{character too large for enclosing character literal type}}
30char m = '👿'; // expected-error {{character too large for enclosing character literal type}}
31
32char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
33char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}}
Richard Smith59b26d82012-06-13 05:41:29 +000034
35char16_t p[2] = u"\U0000FFFF";
Richard Smith0093e122013-03-09 23:56:02 +000036char16_t q[2] = u"\U00010000";
37#ifdef __cplusplus
38// expected-error@-2 {{too long}}
Richard Smith0093e122013-03-09 23:56:02 +000039#endif