summaryrefslogtreecommitdiffstats
path: root/clang/test/Lexer/char-literal.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-03-09 23:56:02 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-03-09 23:56:02 +0000
commit9b36209e31ce6ddba8ed52547b34da6fd98e06cb (patch)
treec8d86d31ada33443be75b62d00ba6a179b6f0c77 /clang/test/Lexer/char-literal.cpp
parentc98bb4ed99364b0816925d642caa1f07b8a27c18 (diff)
downloadbcm5719-llvm-9b36209e31ce6ddba8ed52547b34da6fd98e06cb.tar.gz
bcm5719-llvm-9b36209e31ce6ddba8ed52547b34da6fd98e06cb.zip
When lexing in C11 mode, accept unicode character and string literals, per C11
6.4.4.4/1 and 6.4.5/1. llvm-svn: 176780
Diffstat (limited to 'clang/test/Lexer/char-literal.cpp')
-rw-r--r--clang/test/Lexer/char-literal.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/test/Lexer/char-literal.cpp b/clang/test/Lexer/char-literal.cpp
index 8556d468cba..b2fab34e440 100644
--- a/clang/test/Lexer/char-literal.cpp
+++ b/clang/test/Lexer/char-literal.cpp
@@ -1,4 +1,11 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -Wfour-char-constants -fsyntax-only -verify %s
+
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __CHAR16_TYPE__ char16_t;
+typedef __CHAR32_TYPE__ char32_t;
+#endif
int a = 'ab'; // expected-warning {{multi-character character constant}}
int b = '\xFF\xFF'; // expected-warning {{multi-character character constant}}
@@ -7,7 +14,9 @@ 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}}
+#ifdef __cplusplus
auto f = '\xE2\x8C\x98'; // expected-warning {{multi-character character constant}}
+#endif
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}}
@@ -24,4 +33,11 @@ char32_t n = U'ab'; // expected-error {{Unicode character literals may not conta
char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}}
char16_t p[2] = u"\U0000FFFF";
-char16_t q[2] = u"\U00010000"; // expected-error {{too long}}
+char16_t q[2] = u"\U00010000";
+#ifdef __cplusplus
+// expected-error@-2 {{too long}}
+#else
+// FIXME: The above should be accepted in C11 mode.
+// expected-error@-6 {{must be an initializer list}}
+// expected-error@-6 {{must be an initializer list}}
+#endif
OpenPOWER on IntegriCloud