Seth Cantrell | 7748cbc | 2012-01-18 12:27:10 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s |
Richard Smith | 0093e12 | 2013-03-09 23:56:02 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -Wfour-char-constants -fsyntax-only -verify %s |
| 3 | |
| 4 | #ifndef __cplusplus |
| 5 | typedef __WCHAR_TYPE__ wchar_t; |
| 6 | typedef __CHAR16_TYPE__ char16_t; |
| 7 | typedef __CHAR32_TYPE__ char32_t; |
| 8 | #endif |
Seth Cantrell | 7748cbc | 2012-01-18 12:27:10 +0000 | [diff] [blame] | 9 | |
| 10 | int a = 'ab'; // expected-warning {{multi-character character constant}} |
| 11 | int b = '\xFF\xFF'; // expected-warning {{multi-character character constant}} |
| 12 | int c = 'APPS'; // expected-warning {{multi-character character constant}} |
| 13 | |
| 14 | char d = '⌘'; // expected-error {{character too large for enclosing character literal type}} |
| 15 | char e = '\u2318'; // expected-error {{character too large for enclosing character literal type}} |
| 16 | |
Richard Smith | 0093e12 | 2013-03-09 23:56:02 +0000 | [diff] [blame] | 17 | #ifdef __cplusplus |
Seth Cantrell | 7748cbc | 2012-01-18 12:27:10 +0000 | [diff] [blame] | 18 | auto f = '\xE2\x8C\x98'; // expected-warning {{multi-character character constant}} |
Richard Smith | 0093e12 | 2013-03-09 23:56:02 +0000 | [diff] [blame] | 19 | #endif |
Seth Cantrell | 7748cbc | 2012-01-18 12:27:10 +0000 | [diff] [blame] | 20 | |
| 21 | char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}} |
| 22 | char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}} |
| 23 | |
| 24 | wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}} |
| 25 | wchar_t j = L'\U0010FFFD'; |
| 26 | |
| 27 | char32_t k = U'\U0010FFFD'; |
| 28 | |
| 29 | char l = 'Ø'; // expected-error {{character too large for enclosing character literal type}} |
| 30 | char m = '👿'; // expected-error {{character too large for enclosing character literal type}} |
| 31 | |
| 32 | char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}} |
| 33 | char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}} |
Richard Smith | 59b26d8 | 2012-06-13 05:41:29 +0000 | [diff] [blame] | 34 | |
| 35 | char16_t p[2] = u"\U0000FFFF"; |
Richard Smith | 0093e12 | 2013-03-09 23:56:02 +0000 | [diff] [blame] | 36 | char16_t q[2] = u"\U00010000"; |
| 37 | #ifdef __cplusplus |
| 38 | // expected-error@-2 {{too long}} |
Richard Smith | 0093e12 | 2013-03-09 23:56:02 +0000 | [diff] [blame] | 39 | #endif |