From 36c49e3f258dced101949edabd72e9bc3f1dedc4 Mon Sep 17 00:00:00 2001 From: dim <dim@FreeBSD.org> Date: Fri, 17 Sep 2010 15:54:40 +0000 Subject: Vendor import of clang r114020 (from the release_28 branch): http://llvm.org/svn/llvm-project/cfe/branches/release_28@114020 Approved by: rpaulo (mentor) --- test/Preprocessor/dump-macros-undef.c | 8 +++++++ test/Preprocessor/init.c | 10 +++++++- test/Preprocessor/macro_fn_comma_swallow.c | 23 ++++++++++++------- test/Preprocessor/macro_paste_mscomment.c | 26 --------------------- test/Preprocessor/macro_paste_msextensions.c | 34 ++++++++++++++++++++++++++++ test/Preprocessor/pragma-pushpop-macro.c | 33 +++++++++++++++++++++++++++ test/Preprocessor/pragma_diagnostic.c | 3 +-- test/Preprocessor/pragma_microsoft.c | 20 ++++++++++++++++ test/Preprocessor/pushable-diagnostics.c | 2 +- 9 files changed, 121 insertions(+), 38 deletions(-) create mode 100644 test/Preprocessor/dump-macros-undef.c delete mode 100644 test/Preprocessor/macro_paste_mscomment.c create mode 100644 test/Preprocessor/macro_paste_msextensions.c create mode 100644 test/Preprocessor/pragma-pushpop-macro.c (limited to 'test/Preprocessor') diff --git a/test/Preprocessor/dump-macros-undef.c b/test/Preprocessor/dump-macros-undef.c new file mode 100644 index 0000000..358fd17 --- /dev/null +++ b/test/Preprocessor/dump-macros-undef.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -E -dD %s | FileCheck %s +// PR7818 + +// CHECK: # 1 "{{.+}}.c" +#define X 3 +// CHECK: #define X 3 +#undef X +// CHECK: #undef X diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 8283671..6c27a6c 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -74,9 +74,10 @@ // C94:#define __STDC_VERSION__ 199409L // // -// RUN: %clang_cc1 -fms-extensions -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s +// RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s // // MSEXT-NOT:#define __STDC__ +// MSEXT:#define _INTEGRAL_MAX_BITS 64 // MSEXT:#define __int16 __INT16_TYPE__ // MSEXT:#define __int32 __INT32_TYPE__ // MSEXT:#define __int64 __INT64_TYPE__ @@ -117,6 +118,13 @@ // SCHAR-NOT:#define __UNSIGNED_CHAR__ // SCHAR:#define __clang__ 1 // +// RUN: %clang_cc1 -E -dM -fshort-wchar < /dev/null | FileCheck -check-prefix SHORTWCHAR %s +// +// SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2 +// SHORTWCHAR: #define __WCHAR_MAX__ 65535U +// SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short +// SHORTWCHAR: #define __WCHAR_WIDTH__ 16 +// // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -check-prefix ARM %s // // ARM:#define __APCS_32__ 1 diff --git a/test/Preprocessor/macro_fn_comma_swallow.c b/test/Preprocessor/macro_fn_comma_swallow.c index 5742591..726a889 100644 --- a/test/Preprocessor/macro_fn_comma_swallow.c +++ b/test/Preprocessor/macro_fn_comma_swallow.c @@ -1,21 +1,28 @@ // Test the GNU comma swallowing extension. -// RUN: %clang_cc1 %s -E | grep 'foo{A, }' -// RUN: %clang_cc1 %s -E | grep 'fo2{A,}' -// RUN: %clang_cc1 %s -E | grep '{foo}' +// RUN: %clang_cc1 %s -E | FileCheck -strict-whitespace %s +// CHECK: 1: foo{A, } #define X(Y) foo{A, Y} -X() +1: X() + +// CHECK: 2: fo2{A,} #define X2(Y) fo2{A,##Y} -X2() +2: X2() // should eat the comma. +// CHECK: 3: {foo} #define X3(b, ...) {b, ## __VA_ARGS__} -X3(foo) +3: X3(foo) -// RUN: %clang_cc1 %s -E | grep 'AA BB' // PR3880 +// CHECK: 4: AA BB #define X4(...) AA , ## __VA_ARGS__ BB -X4() +4: X4() + +// PR7943 +// CHECK: 5: 1 +#define X5(x,...) x##,##__VA_ARGS__ +5: X5(1) diff --git a/test/Preprocessor/macro_paste_mscomment.c b/test/Preprocessor/macro_paste_mscomment.c deleted file mode 100644 index 7132406..0000000 --- a/test/Preprocessor/macro_paste_mscomment.c +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -P -E -fms-extensions %s | FileCheck -strict-whitespace %s -// This horrible stuff should preprocess into (other than whitespace): -// int foo; -// int bar; -// int baz; - -int foo; - -// CHECK: int foo; - -#define comment /##/ dead tokens live here -comment This is stupidity - -int bar; - -// CHECK: int bar; - -#define nested(x) int x comment cute little dead tokens... - -nested(baz) rise of the dead tokens - -; - -// CHECK: int baz -// CHECK: ; - diff --git a/test/Preprocessor/macro_paste_msextensions.c b/test/Preprocessor/macro_paste_msextensions.c new file mode 100644 index 0000000..c5b4213 --- /dev/null +++ b/test/Preprocessor/macro_paste_msextensions.c @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -P -E -fms-extensions %s | FileCheck -strict-whitespace %s + +// This horrible stuff should preprocess into (other than whitespace): +// int foo; +// int bar; +// int baz; + +int foo; + +// CHECK: int foo; + +#define comment /##/ dead tokens live here +comment This is stupidity + +int bar; + +// CHECK: int bar; + +#define nested(x) int x comment cute little dead tokens... + +nested(baz) rise of the dead tokens + +; + +// CHECK: int baz +// CHECK: ; + + +// rdar://8197149 - VC++ allows invalid token pastes: (##baz +#define foo(x) abc(x) +#define bar(y) foo(##baz(y)) +bar(q) + +// CHECK: abc(baz(q)) diff --git a/test/Preprocessor/pragma-pushpop-macro.c b/test/Preprocessor/pragma-pushpop-macro.c new file mode 100644 index 0000000..87cceaa --- /dev/null +++ b/test/Preprocessor/pragma-pushpop-macro.c @@ -0,0 +1,33 @@ +/* Test pragma pop_macro and push_macro directives from + http://msdn.microsoft.com/en-us/library/hsttss76.aspx */ + +// pop_macro: Sets the value of the macro_name macro to the value on the top of +// the stack for this macro. +// #pragma pop_macro("macro_name") +// push_macro: Saves the value of the macro_name macro on the top of the stack +// for this macro. +// #pragma push_macro("macro_name") +// +// RUN: %clang_cc1 -fms-extensions -E %s -o - | FileCheck %s + +#define X 1 +#define Y 2 +int pmx0 = X; +int pmy0 = Y; +#define Y 3 +#pragma push_macro("Y") +#pragma push_macro("X") +int pmx1 = X; +#define X 2 +int pmx2 = X; +#pragma pop_macro("X") +int pmx3 = X; +#pragma pop_macro("Y") +int pmy1 = Y; + +// CHECK: int pmx0 = 1 +// CHECK: int pmy0 = 2 +// CHECK: int pmx1 = 1 +// CHECK: int pmx2 = 2 +// CHECK: int pmx3 = 1 +// CHECK: int pmy1 = 3 diff --git a/test/Preprocessor/pragma_diagnostic.c b/test/Preprocessor/pragma_diagnostic.c index d157406..818f02f 100644 --- a/test/Preprocessor/pragma_diagnostic.c +++ b/test/Preprocessor/pragma_diagnostic.c @@ -20,9 +20,8 @@ #endif - #define foo error -#pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', or 'fatal'}} +#pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}} #pragma GCC diagnostic error 42 // expected-warning {{unexpected token in pragma diagnostic}} diff --git a/test/Preprocessor/pragma_microsoft.c b/test/Preprocessor/pragma_microsoft.c index 0201c45..b68d6e3 100644 --- a/test/Preprocessor/pragma_microsoft.c +++ b/test/Preprocessor/pragma_microsoft.c @@ -18,3 +18,23 @@ #pragma comment(user, "foo\abar\nbaz\tsome thing") + +// __pragma + +__pragma(comment(linker," bar=" BAR)) + +#define MACRO_WITH__PRAGMA { \ + __pragma(warning(push)); \ + __pragma(warning(disable: 10000)); \ + 2+2; \ + __pragma(warning(pop)); \ +} + +void f() +{ + __pragma() + + // If we ever actually *support* __pragma(warning(disable: x)), + // this warning should go away. + MACRO_WITH__PRAGMA // expected-warning {{expression result unused}} +} diff --git a/test/Preprocessor/pushable-diagnostics.c b/test/Preprocessor/pushable-diagnostics.c index 6c861a1..567a866f 100644 --- a/test/Preprocessor/pushable-diagnostics.c +++ b/test/Preprocessor/pushable-diagnostics.c @@ -2,7 +2,7 @@ #pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could not pop, no matching push}} -#pragma clang diagnostic puhs // expected-warning{{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal' 'push', or 'pop'}} +#pragma clang diagnostic puhs // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}} char a = 'df'; // expected-warning{{multi-character character constant}} -- cgit v1.1