aboutsummaryrefslogtreecommitdiff
path: root/test/Preprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'test/Preprocessor')
-rw-r--r--test/Preprocessor/dump-macros-undef.c8
-rw-r--r--test/Preprocessor/init.c10
-rw-r--r--test/Preprocessor/macro_fn_comma_swallow.c23
-rw-r--r--test/Preprocessor/macro_paste_msextensions.c (renamed from test/Preprocessor/macro_paste_mscomment.c)8
-rw-r--r--test/Preprocessor/pragma-pushpop-macro.c33
-rw-r--r--test/Preprocessor/pragma_diagnostic.c3
-rw-r--r--test/Preprocessor/pragma_microsoft.c20
-rw-r--r--test/Preprocessor/pushable-diagnostics.c2
8 files changed, 95 insertions, 12 deletions
diff --git a/test/Preprocessor/dump-macros-undef.c b/test/Preprocessor/dump-macros-undef.c
new file mode 100644
index 000000000000..358fd17e468d
--- /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 8283671b6636..6c27a6c4316a 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 57425910b8a9..726a889f55e5 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_msextensions.c
index 71324064f7cd..c5b42130b8ea 100644
--- a/test/Preprocessor/macro_paste_mscomment.c
+++ b/test/Preprocessor/macro_paste_msextensions.c
@@ -1,4 +1,5 @@
// 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;
@@ -24,3 +25,10 @@ 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 000000000000..87cceaa4193a
--- /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 d157406b3dc6..818f02f0b90e 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 0201c451deaa..b68d6e363eb8 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 6c861a1b3b6b..567a866fa339 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}}