diff options
Diffstat (limited to 'test/Lexer')
-rw-r--r-- | test/Lexer/11-27-2007-FloatLiterals.c | 2 | ||||
-rw-r--r-- | test/Lexer/c90.c | 5 | ||||
-rw-r--r-- | test/Lexer/char-escapes.c | 1 | ||||
-rw-r--r-- | test/Lexer/clang-keywords.cpp | 3 | ||||
-rw-r--r-- | test/Lexer/constants.c | 8 | ||||
-rw-r--r-- | test/Lexer/cxx0x_keyword_as_cxx98.cpp | 3 | ||||
-rw-r--r-- | test/Lexer/digraph.c | 2 | ||||
-rw-r--r-- | test/Lexer/has_attribute.cpp | 12 | ||||
-rw-r--r-- | test/Lexer/has_feature_cxx0x.cpp | 58 | ||||
-rw-r--r-- | test/Lexer/has_feature_type_traits.cpp | 91 | ||||
-rw-r--r-- | test/Lexer/ms-extensions.c | 1 | ||||
-rw-r--r-- | test/Lexer/pragma-message.c | 14 | ||||
-rw-r--r-- | test/Lexer/pragma-operators.cpp | 20 | ||||
-rw-r--r-- | test/Lexer/preamble.c | 1 | ||||
-rw-r--r-- | test/Lexer/rdar-8914293.c | 7 | ||||
-rw-r--r-- | test/Lexer/rdr-6096838-2.c | 2 | ||||
-rw-r--r-- | test/Lexer/rdr-6096838.c | 4 | ||||
-rw-r--r-- | test/Lexer/wchar.c | 12 |
18 files changed, 211 insertions, 35 deletions
diff --git a/test/Lexer/11-27-2007-FloatLiterals.c b/test/Lexer/11-27-2007-FloatLiterals.c index ccd9e2e..f3d978b 100644 --- a/test/Lexer/11-27-2007-FloatLiterals.c +++ b/test/Lexer/11-27-2007-FloatLiterals.c @@ -4,8 +4,10 @@ // CHECK: 2.000000e+{{[0]*}}32 // CHECK: 0x3BFD83C940000000 // CHECK: 2.000000e+{{[0]*}}32 +// CHECK: 0x7FF0000000000000 float F = 1e-19f; double D = 2e32; float F2 = 01e-19f; double D2 = 02e32; +float F3 = 0xFp100000000000000000000F; diff --git a/test/Lexer/c90.c b/test/Lexer/c90.c index f191397..d910572 100644 --- a/test/Lexer/c90.c +++ b/test/Lexer/c90.c @@ -27,3 +27,8 @@ void test2() { "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"; } + +void test3() { + (void)L"\u1234"; // expected-error {{unicode escape sequences are only valid in C99 or C++}} + (void)L'\u1234'; // expected-error {{unicode escape sequences are only valid in C99 or C++}} +} diff --git a/test/Lexer/char-escapes.c b/test/Lexer/char-escapes.c index d918bf4..32a1c61 100644 --- a/test/Lexer/char-escapes.c +++ b/test/Lexer/char-escapes.c @@ -19,3 +19,4 @@ int test['\(' == 40 ? 1 : -1]; // expected-warning {{non-standard escape}} int test['\{' == 123 ? 1 : -1]; // expected-warning {{non-standard escape}} int test['\[' == 91 ? 1 : -1]; // expected-warning {{non-standard escape}} int test['\%' == 37 ? 1 : -1]; // expected-warning {{non-standard escape}} +const char *format = "abc \m def"; // expected-warning{{unknown escape sequence '\m'}} diff --git a/test/Lexer/clang-keywords.cpp b/test/Lexer/clang-keywords.cpp new file mode 100644 index 0000000..a349b44 --- /dev/null +++ b/test/Lexer/clang-keywords.cpp @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +__char16_t c16; +void f(__char32_t) { } diff --git a/test/Lexer/constants.c b/test/Lexer/constants.c index de0962e..3d2da2c 100644 --- a/test/Lexer/constants.c +++ b/test/Lexer/constants.c @@ -15,7 +15,7 @@ float Y = 08.123456; #endif -char c[] = { +int c[] = { 'df', // expected-warning {{multi-character character constant}} '\t', '\\ @@ -34,12 +34,12 @@ int m3 = '\\\ #pragma clang diagnostic ignored "-Wmultichar" -char d = 'df'; // no warning. -char e = 'abcd'; // still warn: expected-warning {{multi-character character constant}} +int d = 'df'; // no warning. +int e = 'abcd'; // still warn: expected-warning {{multi-character character constant}} #pragma clang diagnostic ignored "-Wfour-char-constants" -char f = 'abcd'; // ignored. +int f = 'abcd'; // ignored. // rdar://problem/6974641 float t0[] = { diff --git a/test/Lexer/cxx0x_keyword_as_cxx98.cpp b/test/Lexer/cxx0x_keyword_as_cxx98.cpp index 2bfb8b0..0223b03 100644 --- a/test/Lexer/cxx0x_keyword_as_cxx98.cpp +++ b/test/Lexer/cxx0x_keyword_as_cxx98.cpp @@ -1,2 +1,3 @@ -// RUN: %clang_cc1 %s -fsyntax-only +// RUN: %clang_cc1 %s -verify -fsyntax-only int static_assert; +int char16_t; diff --git a/test/Lexer/digraph.c b/test/Lexer/digraph.c index b8a99bb..cf6e478 100644 --- a/test/Lexer/digraph.c +++ b/test/Lexer/digraph.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify < %s +// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s %:include <stdint.h> diff --git a/test/Lexer/has_attribute.cpp b/test/Lexer/has_attribute.cpp new file mode 100644 index 0000000..9a58a30 --- /dev/null +++ b/test/Lexer/has_attribute.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -E %s -o - | FileCheck %s + +// CHECK: always_inline +#if __has_attribute(always_inline) +int always_inline(); +#endif + +// CHECK: no_dummy_attribute +#if !__has_attribute(dummy_attribute) +int no_dummy_attribute(); +#endif + diff --git a/test/Lexer/has_feature_cxx0x.cpp b/test/Lexer/has_feature_cxx0x.cpp index cc2ae28..07a3ebd 100644 --- a/test/Lexer/has_feature_cxx0x.cpp +++ b/test/Lexer/has_feature_cxx0x.cpp @@ -2,7 +2,7 @@ // RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-0X %s #if __has_feature(cxx_lambdas) -int lambdas(); +int has_lambdas(); #else int no_lambdas(); #endif @@ -21,16 +21,6 @@ int no_nullptr(); // CHECK-NO-0X: no_nullptr -#if __has_feature(cxx_concepts) -int concepts(); -#else -int no_concepts(); -#endif - -// CHECK-0X: no_concepts -// CHECK-NO-0X: no_concepts - - #if __has_feature(cxx_decltype) int has_decltype(); #else @@ -42,22 +32,22 @@ int no_decltype(); #if __has_feature(cxx_auto_type) -int auto_type(); +int has_auto_type(); #else int no_auto_type(); #endif -// CHECK-0X: auto_type +// CHECK-0X: has_auto_type // CHECK-NO-0X: no_auto_type #if __has_feature(cxx_attributes) -int attributes(); +int has_attributes(); #else int no_attributes(); #endif -// CHECK-0X: attributes +// CHECK-0X: has_attributes // CHECK-NO-0X: no_attributes @@ -70,42 +60,60 @@ int no_static_assert(); // CHECK-0X: has_static_assert // CHECK-NO-0X: no_static_assert - #if __has_feature(cxx_deleted_functions) -int deleted_functions(); +int has_deleted_functions(); #else int no_deleted_functions(); #endif -// CHECK-0X: deleted_functions +// CHECK-0X: has_deleted_functions // CHECK-NO-0X: no_deleted_functions #if __has_feature(cxx_rvalue_references) -int rvalue_references(); +int has_rvalue_references(); #else int no_rvalue_references(); #endif -// CHECK-0X: no_rvalue_references +// CHECK-0X: has_rvalue_references // CHECK-NO-0X: no_rvalue_references #if __has_feature(cxx_variadic_templates) -int variadic_templates(); +int has_variadic_templates(); #else int no_variadic_templates(); #endif -// CHECK-0X: no_variadic_templates +// CHECK-0X: has_variadic_templates // CHECK-NO-0X: no_variadic_templates #if __has_feature(cxx_inline_namespaces) -int inline_namespaces(); +int has_inline_namespaces(); #else int no_inline_namespaces(); #endif -// CHECK-0X: inline_namespaces -// CHECK-NO-0X: inline_namespaces +// CHECK-0X: has_inline_namespaces +// CHECK-NO-0X: no_inline_namespaces + +#if __has_feature(cxx_reference_qualified_functions) +int has_reference_qualified_functions(); +#else +int no_reference_qualified_functions(); +#endif + +// CHECK-0X: has_reference_qualified_functions +// CHECK-NO-0X: no_reference_qualified_functions + +#if __has_feature(cxx_default_function_template_args) +int has_default_function_template_args(); +#else +int no_default_function_template_args(); +#endif + +// CHECK-0X: has_default_function_template_args +// CHECK-NO-0X: no_default_function_template_args + diff --git a/test/Lexer/has_feature_type_traits.cpp b/test/Lexer/has_feature_type_traits.cpp new file mode 100644 index 0000000..3cfc602 --- /dev/null +++ b/test/Lexer/has_feature_type_traits.cpp @@ -0,0 +1,91 @@ +// RUN: %clang_cc1 -E %s -o - | FileCheck %s + +#if __has_feature(has_nothrow_assign) +int has_nothrow_assign(); +#endif +// CHECK: int has_nothrow_assign(); + +#if __has_feature(has_nothrow_copy) +int has_nothrow_copy(); +#endif +// CHECK: int has_nothrow_copy(); + +#if __has_feature(has_nothrow_constructor) +int has_nothrow_constructor(); +#endif +// CHECK: int has_nothrow_constructor(); + +#if __has_feature(has_trivial_assign) +int has_trivial_assign(); +#endif +// CHECK: int has_trivial_assign(); + +#if __has_feature(has_trivial_copy) +int has_trivial_copy(); +#endif +// CHECK: int has_trivial_copy(); + +#if __has_feature(has_trivial_constructor) +int has_trivial_constructor(); +#endif +// CHECK: int has_trivial_constructor(); + +#if __has_feature(has_trivial_destructor) +int has_trivial_destructor(); +#endif +// CHECK: int has_trivial_destructor(); + +#if __has_feature(has_virtual_destructor) +int has_virtual_destructor(); +#endif +// CHECK: int has_virtual_destructor(); + +#if __has_feature(is_abstract) +int is_abstract(); +#endif +// CHECK: int is_abstract(); + +#if __has_feature(is_base_of) +int is_base_of(); +#endif +// CHECK: int is_base_of(); + +#if __has_feature(is_class) +int is_class(); +#endif +// CHECK: int is_class(); + +#if __has_feature(is_convertible_to) +int is_convertible_to(); +#endif +// CHECK: int is_convertible_to(); + +#if __has_feature(is_empty) +int is_empty(); +#endif +// CHECK: int is_empty(); + +#if __has_feature(is_enum) +int is_enum(); +#endif +// CHECK: int is_enum(); + +#if __has_feature(is_pod) +int is_pod(); +#endif +// CHECK: int is_pod(); + +#if __has_feature(is_polymorphic) +int is_polymorphic(); +#endif +// CHECK: int is_polymorphic(); + +#if __has_feature(is_union) +int is_union(); +#endif +// CHECK: int is_union(); + +#if __has_feature(is_literal) +int is_literal(); +#endif +// CHECK: int is_literal(); diff --git a/test/Lexer/ms-extensions.c b/test/Lexer/ms-extensions.c index 8b7d2e1..9cd868e 100644 --- a/test/Lexer/ms-extensions.c +++ b/test/Lexer/ms-extensions.c @@ -4,6 +4,7 @@ __int8 x1 = 3i8; __int16 x2 = 4i16; __int32 x3 = 5i32; __int64 x5 = 0x42i64; +__int64 x6 = 0x42I64; __int64 x4 = 70000000i128; __int64 y = 0x42i64u; // expected-error {{invalid suffix}} diff --git a/test/Lexer/pragma-message.c b/test/Lexer/pragma-message.c new file mode 100644 index 0000000..710568c --- /dev/null +++ b/test/Lexer/pragma-message.c @@ -0,0 +1,14 @@ +/* Test pragma message directive from + http://msdn.microsoft.com/en-us/library/x7dkzch2.aspx */ + +// message: Sends a string literal to the standard output without terminating +// the compilation. +// #pragma message(messagestring) +// OR +// #pragma message messagestring +// +// RUN: %clang_cc1 -fsyntax-only -verify %s +#define STRING2(x) #x +#define STRING(x) STRING2(x) +#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 13}} +#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 14}} diff --git a/test/Lexer/pragma-operators.cpp b/test/Lexer/pragma-operators.cpp new file mode 100644 index 0000000..d1645ad --- /dev/null +++ b/test/Lexer/pragma-operators.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fms-extensions -E %s | FileCheck %s + +// Test that we properly expand the C99 _Pragma and Microsoft __pragma +// into #pragma directives, with newlines where needed. <rdar://problem/8412013> + +// CHECK: #line +// CHECK: #pragma warning(push) +// CHECK: extern "C" { +// CHECK: #line +// CHECK: #pragma warning(push) +// CHECK: int foo() { return 0; } } +// CHECK: #line +// CHECK: #pragma warning(pop) +#define A(X) extern "C" { __pragma(warning(push)) \ + int X() { return 0; } \ +} +#define B(X) A(X) +#pragma warning(push) +B(foo) +#pragma warning(pop) diff --git a/test/Lexer/preamble.c b/test/Lexer/preamble.c index 69cdbb7..7735b47 100644 --- a/test/Lexer/preamble.c +++ b/test/Lexer/preamble.c @@ -22,7 +22,6 @@ int foo(); // RUN: %clang_cc1 -print-preamble %s > %t // RUN: echo END. >> %t // RUN: FileCheck < %t %s -// XFAIL: win32 // CHECK: // Preamble detection test: see below for comments and test commands. // CHECK-NEXT: // diff --git a/test/Lexer/rdar-8914293.c b/test/Lexer/rdar-8914293.c new file mode 100644 index 0000000..e39e4f1 --- /dev/null +++ b/test/Lexer/rdar-8914293.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// rdar://8914293 +// We want be compatible with gcc and warn, not error. + +/* expected-warning {{missing terminating}} */ #define FOO "foo +/* expected-warning {{missing terminating}} */ #define KOO 'k diff --git a/test/Lexer/rdr-6096838-2.c b/test/Lexer/rdr-6096838-2.c index f7f5906..68aa5e6 100644 --- a/test/Lexer/rdr-6096838-2.c +++ b/test/Lexer/rdr-6096838-2.c @@ -1,4 +1,4 @@ -/* RUN: %clang_cc1 -pedantic -std=gnu89 -fsyntax-only -verify %s +/* RUN: %clang_cc1 -triple x86_64-unknown-unknown -pedantic -std=gnu89 -fsyntax-only -verify %s rdar://6096838 */ diff --git a/test/Lexer/rdr-6096838.c b/test/Lexer/rdr-6096838.c index 2f00f47..d1426cc 100644 --- a/test/Lexer/rdr-6096838.c +++ b/test/Lexer/rdr-6096838.c @@ -1,5 +1,5 @@ -/* RUN: %clang_cc1 -fsyntax-only -verify %s - * RUN: %clang_cc1 -std=gnu89 -fsyntax-only -verify %s +/* RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -verify %s + * RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=gnu89 -fsyntax-only -verify %s rdar://6096838 */ diff --git a/test/Lexer/wchar.c b/test/Lexer/wchar.c new file mode 100644 index 0000000..ac82c1f --- /dev/null +++ b/test/Lexer/wchar.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -fshort-wchar -verify %s + +void f() { + (void)L"\U00010000"; // expected-warning {{character unicode escape sequence too long for its type}} + + (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'a\u1000'; // expected-warning {{extraneous characters in wide character constant ignored}} +} + |