diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2011-10-20 21:14:49 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2011-10-20 21:14:49 +0000 |
commit | 36981b17ed939300f6f8fc2355a255f711fcef71 (patch) | |
tree | ee2483e98b09cac943dc93a6969d83ca737ff139 /test/Lexer | |
parent | 180abc3db9ae3b4fc63cd65b15697e6ffcc8a657 (diff) |
Notes
Diffstat (limited to 'test/Lexer')
-rw-r--r-- | test/Lexer/bcpl-escaped-newline.c | 12 | ||||
-rw-r--r-- | test/Lexer/constants.c | 2 | ||||
-rw-r--r-- | test/Lexer/cxx0x_keyword.cpp | 2 | ||||
-rw-r--r-- | test/Lexer/cxx0x_keyword_as_cxx98.cpp | 37 | ||||
-rw-r--r-- | test/Lexer/cxx0x_raw_string_delim_length.cpp | 3 | ||||
-rw-r--r-- | test/Lexer/cxx0x_raw_string_unterminated.cpp | 4 | ||||
-rw-r--r-- | test/Lexer/has_extension.c | 8 | ||||
-rw-r--r-- | test/Lexer/has_extension_cxx.cpp | 5 | ||||
-rw-r--r-- | test/Lexer/has_feature_c1x.c | 9 | ||||
-rw-r--r-- | test/Lexer/has_feature_cxx0x.cpp | 20 | ||||
-rw-r--r-- | test/Lexer/has_feature_objc_arc.m | 4 | ||||
-rw-r--r-- | test/Lexer/has_feature_type_traits.cpp | 5 | ||||
-rw-r--r-- | test/Lexer/hexfloat.cpp | 9 | ||||
-rw-r--r-- | test/Lexer/newline-eof.c | 5 | ||||
-rw-r--r-- | test/Lexer/preamble.c | 4 | ||||
-rw-r--r-- | test/Lexer/string_concat.cpp | 33 | ||||
-rw-r--r-- | test/Lexer/utf8-char-literal.cpp | 4 | ||||
-rw-r--r-- | test/Lexer/wchar.c | 4 |
18 files changed, 153 insertions, 17 deletions
diff --git a/test/Lexer/bcpl-escaped-newline.c b/test/Lexer/bcpl-escaped-newline.c new file mode 100644 index 0000000000000..4d4a7b5e89ebe --- /dev/null +++ b/test/Lexer/bcpl-escaped-newline.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -Eonly -trigraphs %s +// RUN: %clang_cc1 -Eonly -verify %s + +//\ +#error bar + +//??/ +#error qux // expected-error {{qux}} + +// Trailing whitespace! +//\ +#error quux diff --git a/test/Lexer/constants.c b/test/Lexer/constants.c index 3d2da2c764e6d..013103b1f5dd9 100644 --- a/test/Lexer/constants.c +++ b/test/Lexer/constants.c @@ -65,3 +65,5 @@ double t1[] = { // PR7888 double g = 1e100000000; // expected-warning {{too large}} + +char h = '\u1234'; // expected-warning {{character unicode escape sequence too long for its type}} diff --git a/test/Lexer/cxx0x_keyword.cpp b/test/Lexer/cxx0x_keyword.cpp index c27925bcfee4f..e6841ef7665d0 100644 --- a/test/Lexer/cxx0x_keyword.cpp +++ b/test/Lexer/cxx0x_keyword.cpp @@ -1,2 +1,2 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s 2>&1 +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2>&1 int static_assert; /* expected-error {{expected unqualified-id}} */ diff --git a/test/Lexer/cxx0x_keyword_as_cxx98.cpp b/test/Lexer/cxx0x_keyword_as_cxx98.cpp index 0223b039be929..d87d3dc7faffb 100644 --- a/test/Lexer/cxx0x_keyword_as_cxx98.cpp +++ b/test/Lexer/cxx0x_keyword_as_cxx98.cpp @@ -1,3 +1,36 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -int static_assert; -int char16_t; + +#define constexpr const +constexpr int x = 0; +#undef constexpr + +namespace lib { + struct nullptr_t; + typedef nullptr_t nullptr; // expected-warning {{'nullptr' is a keyword in C++11}} +} + +#define CONCAT(X,Y) CONCAT2(X,Y) +#define CONCAT2(X,Y) X ## Y +int CONCAT(constexpr,ession); + +#define ID(X) X +extern int ID(decltype); // expected-warning {{'decltype' is a keyword in C++11}} + +extern int CONCAT(align,of); // expected-warning {{'alignof' is a keyword in C++11}} + +#define static_assert(b, s) int CONCAT(check, __LINE__)[(b) ? 1 : 0]; +static_assert(1 > 0, "hello"); // ok + +#define IF_CXX11(CXX11, CXX03) CXX03 +typedef IF_CXX11(char16_t, wchar_t) my_wide_char_t; // ok + +int alignas; // expected-warning {{'alignas' is a keyword in C++11}} +int alignof; // already diagnosed in this TU +int char16_t; // expected-warning {{'char16_t' is a keyword in C++11}} +int char32_t; // expected-warning {{'char32_t' is a keyword in C++11}} +int constexpr; // expected-warning {{'constexpr' is a keyword in C++11}} +int decltype; // already diagnosed in this TU +int noexcept; // expected-warning {{'noexcept' is a keyword in C++11}} +int nullptr; // already diagnosed in this TU +int static_assert; // expected-warning {{'static_assert' is a keyword in C++11}} +int thread_local; // expected-warning {{'thread_local' is a keyword in C++11}} diff --git a/test/Lexer/cxx0x_raw_string_delim_length.cpp b/test/Lexer/cxx0x_raw_string_delim_length.cpp new file mode 100644 index 0000000000000..e7d5c6f8cd274 --- /dev/null +++ b/test/Lexer/cxx0x_raw_string_delim_length.cpp @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -std=c++11 -E %s 2>&1 | grep 'error: raw string delimiter longer than 16 characters' + +const char *str = R"abcdefghijkmnopqrstuvwxyz(abcdef)abcdefghijkmnopqrstuvwxyz"; diff --git a/test/Lexer/cxx0x_raw_string_unterminated.cpp b/test/Lexer/cxx0x_raw_string_unterminated.cpp new file mode 100644 index 0000000000000..dfbaaeee1e72b --- /dev/null +++ b/test/Lexer/cxx0x_raw_string_unterminated.cpp @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -std=c++11 -E %s 2>&1 | grep 'error: raw string missing terminating delimiter )foo"' + +const char *str = R"foo(abc +def)bar"; diff --git a/test/Lexer/has_extension.c b/test/Lexer/has_extension.c index bc75a4a1c5468..4c322c7ce7a3b 100644 --- a/test/Lexer/has_extension.c +++ b/test/Lexer/has_extension.c @@ -28,3 +28,11 @@ int has_c_generic_selections(); int no_c_generic_selections(); #endif +// CHECK-PED-NONE: has_c_alignas +// CHECK-PED-ERR: no_c_alignas +#if __has_extension(c_alignas) +int has_c_alignas(); +#else +int no_c_alignas(); +#endif + diff --git a/test/Lexer/has_extension_cxx.cpp b/test/Lexer/has_extension_cxx.cpp index 77efa357938c7..5481b596cc4a3 100644 --- a/test/Lexer/has_extension_cxx.cpp +++ b/test/Lexer/has_extension_cxx.cpp @@ -25,6 +25,11 @@ int has_inline_namespaces(); int has_override_control(); #endif +// CHECK: has_range_for +#if __has_extension(cxx_range_for) +int has_range_for(); +#endif + // CHECK: has_reference_qualified_functions #if __has_extension(cxx_reference_qualified_functions) int has_reference_qualified_functions(); diff --git a/test/Lexer/has_feature_c1x.c b/test/Lexer/has_feature_c1x.c index 6c0fb212cce3d..ca4e9b95ad04b 100644 --- a/test/Lexer/has_feature_c1x.c +++ b/test/Lexer/has_feature_c1x.c @@ -18,3 +18,12 @@ int no_generic_selections(); // CHECK-1X: has_generic_selections // CHECK-NO-1X: no_generic_selections + +#if __has_feature(c_alignas) +int has_alignas(); +#else +int no_alignas(); +#endif + +// CHECK-1X: has_alignas +// CHECK-NO-1X: no_alignas diff --git a/test/Lexer/has_feature_cxx0x.cpp b/test/Lexer/has_feature_cxx0x.cpp index ca5f868d9b056..f2b4576b57e96 100644 --- a/test/Lexer/has_feature_cxx0x.cpp +++ b/test/Lexer/has_feature_cxx0x.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -E -std=c++0x %s -o - | FileCheck --check-prefix=CHECK-0X %s +// RUN: %clang_cc1 -E -std=c++11 %s -o - | FileCheck --check-prefix=CHECK-0X %s // RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-0X %s #if __has_feature(cxx_lambdas) @@ -164,3 +164,21 @@ int no_alias_templates(); // CHECK-0X: has_alias_templates // CHECK-NO-0X: no_alias_templates + +#if __has_feature(cxx_implicit_moves) +int has_implicit_moves(); +#else +int no_implicit_moves(); +#endif + +// CHECK-0X: has_implicit_moves +// CHECK-NO-0X: no_implicit_moves + +#if __has_feature(cxx_alignas) +int has_alignas(); +#else +int no_alignas(); +#endif + +// CHECK-0X: has_alignas +// CHECK-NO-0X: no_alignas diff --git a/test/Lexer/has_feature_objc_arc.m b/test/Lexer/has_feature_objc_arc.m index cd41900c60b70..279b91af39cd7 100644 --- a/test/Lexer/has_feature_objc_arc.m +++ b/test/Lexer/has_feature_objc_arc.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -E %s -fobjc-nonfragile-abi -fobjc-arc "-triple" "x86_64-apple-macosx10.7.0" -fobjc-runtime-has-weak | FileCheck --check-prefix=CHECK-ARC %s -// RUN: %clang_cc1 -E %s -fobjc-nonfragile-abi -fobjc-arc "-triple" "x86_64-apple-macosx10.6.0" | FileCheck --check-prefix=CHECK-ARCLITE %s +// RUN: %clang_cc1 -E %s -fobjc-arc "-triple" "x86_64-apple-macosx10.7.0" -fobjc-runtime-has-weak | FileCheck --check-prefix=CHECK-ARC %s +// RUN: %clang_cc1 -E %s -fobjc-arc "-triple" "x86_64-apple-macosx10.6.0" | FileCheck --check-prefix=CHECK-ARCLITE %s #if __has_feature(objc_arc) void has_objc_arc_feature(); diff --git a/test/Lexer/has_feature_type_traits.cpp b/test/Lexer/has_feature_type_traits.cpp index 5da845f065120..53056a02b72a5 100644 --- a/test/Lexer/has_feature_type_traits.cpp +++ b/test/Lexer/has_feature_type_traits.cpp @@ -99,3 +99,8 @@ int is_standard_layout(); int is_trivially_copyable(); #endif // CHECK: int is_trivially_copyable(); + +#if __has_feature(underlying_type) +int underlying_type(); +#endif +// CHECK: int underlying_type(); diff --git a/test/Lexer/hexfloat.cpp b/test/Lexer/hexfloat.cpp index 493b64e627402..23daa49ad2109 100644 --- a/test/Lexer/hexfloat.cpp +++ b/test/Lexer/hexfloat.cpp @@ -1,9 +1,4 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s -// XFAIL: * +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s +float f = 0x1p+1; // expected-warning{{hexadecimal floating constants are a C99 feature}} -#ifndef __GXX_EXPERIMENTAL_CXX0X__ -float f = 0x1p+1; // expected-warning {{incompatible with C++0x}} -#else -float f = 0x1p+1; // expected-warning {{invalid suffix}} -#endif diff --git a/test/Lexer/newline-eof.c b/test/Lexer/newline-eof.c new file mode 100644 index 0000000000000..2f95dc7593c7a --- /dev/null +++ b/test/Lexer/newline-eof.c @@ -0,0 +1,5 @@ +// RUN: %clang -fsyntax-only -Wnewline-eof -verify %s +// rdar://9133072 + +// The following line isn't terminated, don't fix it. +void foo() {} // expected-warning{{No newline at end of file}}
\ No newline at end of file diff --git a/test/Lexer/preamble.c b/test/Lexer/preamble.c index 7735b475e1ae8..5b2739abefcc9 100644 --- a/test/Lexer/preamble.c +++ b/test/Lexer/preamble.c @@ -1,5 +1,5 @@ // Preamble detection test: see below for comments and test commands. -// +//* A BCPL comment that includes '/*' #include <blah> #ifndef FOO #else @@ -24,7 +24,7 @@ int foo(); // RUN: FileCheck < %t %s // CHECK: // Preamble detection test: see below for comments and test commands. -// CHECK-NEXT: // +// CHECK-NEXT: //* A BCPL comment that includes '/*' // CHECK-NEXT: #include <blah> // CHECK-NEXT: #ifndef FOO // CHECK-NEXT: #else diff --git a/test/Lexer/string_concat.cpp b/test/Lexer/string_concat.cpp new file mode 100644 index 0000000000000..43782bce8c508 --- /dev/null +++ b/test/Lexer/string_concat.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +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 }} + 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 }} + + 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 }} + 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 }} + + 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 }} + 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 }} + + 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 }} + 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 }} +} + diff --git a/test/Lexer/utf8-char-literal.cpp b/test/Lexer/utf8-char-literal.cpp new file mode 100644 index 0000000000000..c4ea5fc3c3e9d --- /dev/null +++ b/test/Lexer/utf8-char-literal.cpp @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -fsyntax-only -verify %s + +int array0[u'ñ' == u'\xf1'? 1 : -1]; +int array1['ñ' != u'\xf1'? 1 : -1]; diff --git a/test/Lexer/wchar.c b/test/Lexer/wchar.c index ac82c1f73b4d9..648a38ef3f9af 100644 --- a/test/Lexer/wchar.c +++ b/test/Lexer/wchar.c @@ -5,8 +5,8 @@ void f() { (void)L'\U00010000'; // expected-warning {{character unicode escape sequence too long for its type}} - (void)L'ab'; // expected-warning {{extraneous characters in wide character constant ignored}} + (void)L'ab'; // expected-warning {{extraneous characters in character constant ignored}} - (void)L'a\u1000'; // expected-warning {{extraneous characters in wide character constant ignored}} + (void)L'a\u1000'; // expected-warning {{extraneous characters in character constant ignored}} } |