summaryrefslogtreecommitdiff
path: root/test/Lexer/char-literal.cpp
diff options
context:
space:
mode:
authorSeth Cantrell <seth.cantrell@gmail.com>2012-01-18 12:27:10 +0000
committerSeth Cantrell <seth.cantrell@gmail.com>2012-01-18 12:27:10 +0000
commit7748cbc97ff9c6c3940549d30965a10b47a45ee8 (patch)
tree6221bd3972fa668a58b31ec1e8470e65a63f3ce7 /test/Lexer/char-literal.cpp
parent5393e213f1d86a64e8e6b549c0ef76f9286ce279 (diff)
downloadclang-7748cbc97ff9c6c3940549d30965a10b47a45ee8.tar.gz
Add and update tests for character literals
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148392 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Lexer/char-literal.cpp')
-rw-r--r--test/Lexer/char-literal.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/Lexer/char-literal.cpp b/test/Lexer/char-literal.cpp
new file mode 100644
index 0000000000..5dc53608f8
--- /dev/null
+++ b/test/Lexer/char-literal.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s
+
+int a = 'ab'; // expected-warning {{multi-character character constant}}
+int b = '\xFF\xFF'; // expected-warning {{multi-character character constant}}
+int c = 'APPS'; // expected-warning {{multi-character character constant}}
+
+char d = '⌘'; // expected-error {{character too large for enclosing character literal type}}
+char e = '\u2318'; // expected-error {{character too large for enclosing character literal type}}
+
+auto f = '\xE2\x8C\x98'; // expected-warning {{multi-character character constant}}
+
+char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
+char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}}
+
+wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
+wchar_t j = L'\U0010FFFD';
+
+char32_t k = U'\U0010FFFD';
+
+char l = 'Ø'; // expected-error {{character too large for enclosing character literal type}}
+char m = '👿'; // expected-error {{character too large for enclosing character literal type}}
+
+char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
+char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}}