aboutsummaryrefslogtreecommitdiff
path: root/test/Lexer
diff options
context:
space:
mode:
Diffstat (limited to 'test/Lexer')
-rw-r--r--test/Lexer/char-literal.cpp18
-rw-r--r--test/Lexer/string_concat.cpp15
-rw-r--r--test/Lexer/utf8-char-literal.cpp1
3 files changed, 33 insertions, 1 deletions
diff --git a/test/Lexer/char-literal.cpp b/test/Lexer/char-literal.cpp
index 8556d468cb..b2fab34e44 100644
--- a/test/Lexer/char-literal.cpp
+++ b/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
diff --git a/test/Lexer/string_concat.cpp b/test/Lexer/string_concat.cpp
index 7e78a63e2f..a7eb396fe9 100644
--- a/test/Lexer/string_concat.cpp
+++ b/test/Lexer/string_concat.cpp
@@ -1,33 +1,48 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c11 -x c -fsyntax-only -verify %s
+
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __CHAR16_TYPE__ char16_t;
+typedef __CHAR32_TYPE__ char32_t;
+#endif
void f() {
const char* a = u8"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char* b = u8"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char* c = u8"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+#ifdef __cplusplus
const char* d = u8"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char* e = u8"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char* f = u8"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+#endif
const char16_t* g = u"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char16_t* h = u"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char16_t* i = u"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+#ifdef __cplusplus
const char16_t* j = u"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char16_t* k = u"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char16_t* l = u"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+#endif
const char32_t* m = U"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char32_t* n = U"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char32_t* o = U"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+#ifdef __cplusplus
const char32_t* p = U"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char32_t* q = U"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
const char32_t* r = U"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+#endif
const wchar_t* s = L"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
const wchar_t* t = L"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
const wchar_t* u = L"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+#ifdef __cplusplus
const wchar_t* v = L"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
const wchar_t* w = L"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
const wchar_t* x = L"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+#endif
}
diff --git a/test/Lexer/utf8-char-literal.cpp b/test/Lexer/utf8-char-literal.cpp
index 12b001e4b4..7a4d126097 100644
--- a/test/Lexer/utf8-char-literal.cpp
+++ b/test/Lexer/utf8-char-literal.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -fsyntax-only -verify %s
int array0[u'ñ' == u'\xf1'? 1 : -1];
int array1['\xF1' != u'\xf1'? 1 : -1];