summaryrefslogtreecommitdiffstats
path: root/test/Preprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'test/Preprocessor')
-rw-r--r--test/Preprocessor/_Pragma-dependency.c5
-rw-r--r--test/Preprocessor/_Pragma-physloc.c5
-rw-r--r--test/Preprocessor/aarch64-target-features.c30
-rw-r--r--test/Preprocessor/builtin_line.c6
-rw-r--r--test/Preprocessor/c90.c5
-rw-r--r--test/Preprocessor/disabled-cond-diags.c3
-rw-r--r--test/Preprocessor/feature_tests.c20
-rw-r--r--test/Preprocessor/first-line-indent.c7
-rw-r--r--test/Preprocessor/has_include.c66
-rw-r--r--test/Preprocessor/hash_line.c9
-rw-r--r--test/Preprocessor/init.c195
-rw-r--r--test/Preprocessor/invalid-__has_warning1.c5
-rw-r--r--test/Preprocessor/invalid-__has_warning2.c5
-rw-r--r--test/Preprocessor/iwithprefix.c17
-rw-r--r--test/Preprocessor/line-directive-output.c4
-rw-r--r--test/Preprocessor/macro-multiline.c.ignoreme (renamed from test/Preprocessor/macro-multiline.c)0
-rw-r--r--test/Preprocessor/macro_arg_slocentry_merge.c7
-rw-r--r--test/Preprocessor/macro_arg_slocentry_merge.h7
-rw-r--r--test/Preprocessor/macro_expand.c8
-rw-r--r--test/Preprocessor/macro_expandloc.c9
-rw-r--r--test/Preprocessor/macro_expandloc2.c6
-rw-r--r--test/Preprocessor/macro_fn.c12
-rw-r--r--test/Preprocessor/macro_misc.c14
-rw-r--r--test/Preprocessor/macro_rescan.c14
-rw-r--r--test/Preprocessor/macro_space.c3
-rw-r--r--test/Preprocessor/macro_variadic.cl3
-rw-r--r--test/Preprocessor/microsoft-import.c11
-rw-r--r--test/Preprocessor/output_paste_avoid.c33
-rw-r--r--test/Preprocessor/output_paste_avoid.cpp47
-rw-r--r--test/Preprocessor/pp-record.c11
-rw-r--r--test/Preprocessor/pragma_diagnostic.c2
-rw-r--r--test/Preprocessor/pragma_microsoft.c7
-rw-r--r--test/Preprocessor/pragma_unknown.c3
-rw-r--r--test/Preprocessor/predefined-arch-macros.c161
-rw-r--r--test/Preprocessor/predefined-macros.c18
-rw-r--r--test/Preprocessor/print_line_count.c5
-rw-r--r--test/Preprocessor/print_line_include.c6
-rw-r--r--test/Preprocessor/print_line_include.h1
-rw-r--r--test/Preprocessor/skipping_unclean.c3
-rw-r--r--test/Preprocessor/stringize_space.c12
-rw-r--r--test/Preprocessor/stringize_space2.c6
-rw-r--r--test/Preprocessor/traditional-cpp.c82
-rw-r--r--test/Preprocessor/ucn-allowed-chars.c78
-rw-r--r--test/Preprocessor/ucn-pp-identifier.c106
-rw-r--r--test/Preprocessor/utf8-allowed-chars.c68
-rw-r--r--test/Preprocessor/warn-disabled-macro-expansion.c10
-rw-r--r--test/Preprocessor/warning_tests.c27
47 files changed, 1063 insertions, 99 deletions
diff --git a/test/Preprocessor/_Pragma-dependency.c b/test/Preprocessor/_Pragma-dependency.c
index a2861c9..4534cc2 100644
--- a/test/Preprocessor/_Pragma-dependency.c
+++ b/test/Preprocessor/_Pragma-dependency.c
@@ -1,7 +1,6 @@
-// RUN: %clang_cc1 %s -E 2>&1 | grep 'DO_PRAGMA (STR'
-// RUN: %clang_cc1 %s -E 2>&1 | grep '7:3'
+// RUN: %clang_cc1 -E -verify %s
#define DO_PRAGMA _Pragma
#define STR "GCC dependency \"parse.y\"")
- // Test that this line is printed by caret diagnostics.
+// expected-error@+1 {{'parse.y' file not found}}
DO_PRAGMA (STR
diff --git a/test/Preprocessor/_Pragma-physloc.c b/test/Preprocessor/_Pragma-physloc.c
index a093af2..6d1dcdb 100644
--- a/test/Preprocessor/_Pragma-physloc.c
+++ b/test/Preprocessor/_Pragma-physloc.c
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 %s -E | grep '#pragma x y z'
-// RUN: %clang_cc1 %s -E | grep '#pragma a b c'
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+// CHECK: {{^}}#pragma x y z{{$}}
+// CHECK: {{^}}#pragma a b c{{$}}
_Pragma("x y z")
_Pragma("a b c")
diff --git a/test/Preprocessor/aarch64-target-features.c b/test/Preprocessor/aarch64-target-features.c
new file mode 100644
index 0000000..65104e3
--- /dev/null
+++ b/test/Preprocessor/aarch64-target-features.c
@@ -0,0 +1,30 @@
+// RUN: %clang -target aarch64-none-linux-gnu -x c -E -dM %s -o - | FileCheck %s
+// CHECK: __AARCH 8
+// CHECK: __AARCH64EL__
+// CHECK: __AARCH_ACLE 101
+// CHECK-NOT: __AARCH_ADVSIMD_FP
+// CHECK-NOT: __AARCH_FEATURE_ADVSIMD
+// CHECK-NOT: __AARCH_FEATURE_BIG_ENDIAN
+// CHECK: __AARCH_FEATURE_CLZ 1
+// CHECK: __AARCH_FEATURE_FMA 1
+// CHECK: __AARCH_FEATURE_LDREX 0xf
+// CHECK: __AARCH_FEATURE_UNALIGNED 1
+// CHECK: __AARCH_FP 0xe
+// CHECK-NOT: __AARCH_FP_FAST
+// CHECK: __AARCH_FP16_FORMAT_IEEE 1
+// CHECK: __AARCH_FP_FENV_ROUNDING 1
+// CHECK: __AARCH_PROFILE 'A'
+// CHECK: __AARCH_SIZEOF_MINIMAL_ENUM 4
+// CHECK: __AARCH_SIZEOF_WCHAR_T 4
+// CHECK: __aarch64__
+
+
+// RUN: %clang -target aarch64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
+// CHECK-FASTMATH: __AARCH_FP_FAST
+
+// RUN: %clang -target aarch64-none-linux-gnu -fshort-wchar -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SHORTWCHAR %s
+// CHECK-SHORTWCHAR: __AARCH_SIZEOF_WCHAR_T 2
+
+// RUN: %clang -target aarch64-none-linux-gnu -fshort-enums -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SHORTENUMS %s
+// CHECK-SHORTENUMS: __AARCH_SIZEOF_MINIMAL_ENUM 1
+
diff --git a/test/Preprocessor/builtin_line.c b/test/Preprocessor/builtin_line.c
index 52228b5..db5a103 100644
--- a/test/Preprocessor/builtin_line.c
+++ b/test/Preprocessor/builtin_line.c
@@ -1,13 +1,15 @@
-// RUN: %clang_cc1 %s -E | grep "^ 4"
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
#define FOO __LINE__
FOO
+// CHECK: {{^}} 4{{$}}
// PR3579 - This should expand to the __LINE__ of the ')' not of the X.
-// RUN: %clang_cc1 %s -E | grep "^A 13"
#define X() __LINE__
A X(
)
+// CHECK: {{^}}A 13{{$}}
+
diff --git a/test/Preprocessor/c90.c b/test/Preprocessor/c90.c
index 1d5010d..3b9105f 100644
--- a/test/Preprocessor/c90.c
+++ b/test/Preprocessor/c90.c
@@ -1,4 +1,5 @@
/* RUN: %clang_cc1 %s -std=c89 -Eonly -verify -pedantic-errors
+ * RUN: %clang_cc1 %s -std=c89 -E | FileCheck %s
*/
/* PR3919 */
@@ -8,3 +9,7 @@
#define foo3$bar /* expected-error {{'$' in identifier}} */
+/* CHECK-NOT: this comment should be missing
+ * CHECK: {{^}}// this comment should be present{{$}}
+ */
+// this comment should be present
diff --git a/test/Preprocessor/disabled-cond-diags.c b/test/Preprocessor/disabled-cond-diags.c
index 531842a..0237b5d 100644
--- a/test/Preprocessor/disabled-cond-diags.c
+++ b/test/Preprocessor/disabled-cond-diags.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s 2>&1 | not grep "warning\|error"
+// RUN: %clang_cc1 -E -verify %s
+// expected-no-diagnostics
#if 0
diff --git a/test/Preprocessor/feature_tests.c b/test/Preprocessor/feature_tests.c
index b78a251..19d8046 100644
--- a/test/Preprocessor/feature_tests.c
+++ b/test/Preprocessor/feature_tests.c
@@ -32,3 +32,23 @@
__has_builtin(__builtin_altivec_abs_v4sf)
#error Broken handling of target-specific builtins
#endif
+
+// Macro expansion does not occur in the parameter to __has_builtin,
+// __has_feature, etc. (as is also expected behaviour for ordinary
+// macros), so the following should not expand:
+
+#define MY_ALIAS_BUILTIN __c11_atomic_init
+#define MY_ALIAS_FEATURE attribute_overloadable
+
+#if __has_builtin(MY_ALIAS_BUILTIN) || __has_feature(MY_ALIAS_FEATURE)
+#error Alias expansion not allowed
+#endif
+
+// But deferring should expand:
+
+#define HAS_BUILTIN(X) __has_builtin(X)
+#define HAS_FEATURE(X) __has_feature(X)
+
+#if !HAS_BUILTIN(MY_ALIAS_BUILTIN) || !HAS_FEATURE(MY_ALIAS_FEATURE)
+#error Expansion should have occurred
+#endif
diff --git a/test/Preprocessor/first-line-indent.c b/test/Preprocessor/first-line-indent.c
new file mode 100644
index 0000000..d220d57
--- /dev/null
+++ b/test/Preprocessor/first-line-indent.c
@@ -0,0 +1,7 @@
+ foo
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+ bar
+
+// CHECK: {{^ }}foo
+// CHECK: {{^ }}bar
+
diff --git a/test/Preprocessor/has_include.c b/test/Preprocessor/has_include.c
index 10f7795..131e519 100644
--- a/test/Preprocessor/has_include.c
+++ b/test/Preprocessor/has_include.c
@@ -64,6 +64,55 @@
#error "defined(__has_include_next) failed (8)."
#endif
+// Fun with macros
+#define MACRO1 __has_include(<stdint.h>)
+#define MACRO2 ("stdint.h")
+#define MACRO3 ("blahblah.h")
+#define MACRO4 blahblah.h>)
+#define MACRO5 <stdint.h>
+
+#if !MACRO1
+ #error "__has_include with macro failed (1)."
+#endif
+
+#if !__has_include MACRO2
+ #error "__has_include with macro failed (2)."
+#endif
+
+#if __has_include MACRO3
+ #error "__has_include with macro failed (3)."
+#endif
+
+#if __has_include(<MACRO4
+ #error "__has_include with macro failed (4)."
+#endif
+
+#if !__has_include(MACRO5)
+ #error "__has_include with macro failed (2)."
+#endif
+
+// Try as non-preprocessor directives
+void foo( void ) {
+ __has_include_next("stdint.h") // expected-warning {{#include_next in primary source file}} expected-error {{__has_include_next must be used within a preprocessing directive}}
+ __has_include("stdint.h") // expected-error {{__has_include must be used within a preprocessing directive}}
+}
+
+MACRO1 // expected-error {{__has_include must be used within a preprocessing directive}}
+
+#if 1
+MACRO1 // expected-error {{__has_include must be used within a preprocessing directive}}
+#endif
+
+#if 0
+#elif 1
+MACRO1 // expected-error {{__has_include must be used within a preprocessing directive}}
+#endif
+
+#if 0
+MACRO1 // This should be fine because it is never actually reached
+#endif
+
+
// Try badly formed expressions.
// FIXME: We can recover better in almost all of these cases. (PR13335)
@@ -99,7 +148,7 @@
#if __has_include(stdint.h>)
#endif
-// expected-error@+1 {{missing '(' after '__has_include'}}
+// expected-error@+1 {{__has_include must be used within a preprocessing directive}}
__has_include
// expected-error@+1 {{missing ')' after '__has_include'}} // expected-error@+1 {{expected value in expression}} // expected-note@+1 {{to match this '('}}
@@ -121,3 +170,18 @@ __has_include
// expected-error@+1 {{expected "FILENAME" or <FILENAME>}} // expected-error@+1 {{expected value in expression}}
#if __has_include(<stdint.h)
#endif
+
+#define HAS_INCLUDE(header) __has_include(header)
+#if HAS_INCLUDE(<stdint.h>)
+#else
+ #error "__has_include failed (9)."
+#endif
+
+#if FOO
+#elif __has_include(<foo>)
+#endif
+
+// PR15539
+#ifdef FOO
+#elif __has_include(<foo>)
+#endif
diff --git a/test/Preprocessor/hash_line.c b/test/Preprocessor/hash_line.c
index 4f724df..64edae0 100644
--- a/test/Preprocessor/hash_line.c
+++ b/test/Preprocessor/hash_line.c
@@ -1,7 +1,10 @@
// The 1 and # should not go on the same line.
-// RUN: %clang_cc1 %s -E | not grep "1 #"
-// RUN: %clang_cc1 %s -E | grep '^1$'
-// RUN: %clang_cc1 %s -E | grep '^ #$'
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+// CHECK-NOT: 1{{.*}}#
+// CHECK: {{^1$}}
+// CHECK-NOT: 1{{.*}}#
+// CHECK: {{^ #$}}
+// CHECK-NOT: 1{{.*}}#
1
#define EMPTY
EMPTY #
diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c
index 33a21a3..90b8466 100644
--- a/test/Preprocessor/init.c
+++ b/test/Preprocessor/init.c
@@ -9,14 +9,14 @@
// BLOCKS:#define __block __attribute__((__blocks__(byref)))
//
//
-// RUN: %clang_cc1 -x c++ -std=c++11 -E -dM < /dev/null | FileCheck -check-prefix CXX0X %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -E -dM < /dev/null | FileCheck -check-prefix CXX11 %s
//
-// CXX0X:#define __GNUG__
-// CXX0X:#define __GXX_EXPERIMENTAL_CXX0X__ 1
-// CXX0X:#define __GXX_RTTI 1
-// CXX0X:#define __GXX_WEAK__ 1
-// CXX0X:#define __cplusplus 201103L
-// CXX0X:#define __private_extern__ extern
+// CXX11:#define __GNUG__
+// CXX11:#define __GXX_EXPERIMENTAL_CXX0X__ 1
+// CXX11:#define __GXX_RTTI 1
+// CXX11:#define __GXX_WEAK__ 1
+// CXX11:#define __cplusplus 201103L
+// CXX11:#define __private_extern__ extern
//
//
// RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck -check-prefix CXX98 %s
@@ -248,6 +248,7 @@
// ARM:#define __SIZEOF_SIZE_T__ 4
// ARM:#define __SIZEOF_WCHAR_T__ 4
// ARM:#define __SIZEOF_WINT_T__ 4
+// ARM:#define __SIZE_MAX__ 4294967295U
// ARM:#define __SIZE_TYPE__ unsigned int
// ARM:#define __SIZE_WIDTH__ 32
// ARM:#define __THUMB_INTERWORK__ 1
@@ -351,6 +352,7 @@
// ARMEABISOFTFP:#define __SIZEOF_SIZE_T__ 4
// ARMEABISOFTFP:#define __SIZEOF_WCHAR_T__ 4
// ARMEABISOFTFP:#define __SIZEOF_WINT_T__ 4
+// ARMEABISOFTFP:#define __SIZE_MAX__ 4294967295U
// ARMEABISOFTFP:#define __SIZE_TYPE__ unsigned int
// ARMEABISOFTFP:#define __SIZE_WIDTH__ 32
// ARMEABISOFTFP:#define __SOFTFP__ 1
@@ -455,6 +457,7 @@
// ARMEABIHARDFP:#define __SIZEOF_SIZE_T__ 4
// ARMEABIHARDFP:#define __SIZEOF_WCHAR_T__ 4
// ARMEABIHARDFP:#define __SIZEOF_WINT_T__ 4
+// ARMEABIHARDFP:#define __SIZE_MAX__ 4294967295U
// ARMEABIHARDFP:#define __SIZE_TYPE__ unsigned int
// ARMEABIHARDFP:#define __SIZE_WIDTH__ 32
// ARMEABIHARDFP-NOT:#define __SOFTFP__ 1
@@ -554,6 +557,7 @@
// I386:#define __SIZEOF_SIZE_T__ 4
// I386:#define __SIZEOF_WCHAR_T__ 4
// I386:#define __SIZEOF_WINT_T__ 4
+// I386:#define __SIZE_MAX__ 4294967295U
// I386:#define __SIZE_TYPE__ unsigned int
// I386:#define __SIZE_WIDTH__ 32
// I386:#define __UINTMAX_TYPE__ long long unsigned int
@@ -651,6 +655,7 @@
// I386-LINUX:#define __SIZEOF_SIZE_T__ 4
// I386-LINUX:#define __SIZEOF_WCHAR_T__ 4
// I386-LINUX:#define __SIZEOF_WINT_T__ 4
+// I386-LINUX:#define __SIZE_MAX__ 4294967295U
// I386-LINUX:#define __SIZE_TYPE__ unsigned int
// I386-LINUX:#define __SIZE_WIDTH__ 32
// I386-LINUX:#define __UINTMAX_TYPE__ long long unsigned int
@@ -759,6 +764,7 @@
// MIPS32BE:#define __SIZEOF_SIZE_T__ 4
// MIPS32BE:#define __SIZEOF_WCHAR_T__ 4
// MIPS32BE:#define __SIZEOF_WINT_T__ 4
+// MIPS32BE:#define __SIZE_MAX__ 4294967295U
// MIPS32BE:#define __SIZE_TYPE__ unsigned int
// MIPS32BE:#define __SIZE_WIDTH__ 32
// MIPS32BE:#define __STDC_HOSTED__ 0
@@ -875,6 +881,7 @@
// MIPS32EL:#define __SIZEOF_SIZE_T__ 4
// MIPS32EL:#define __SIZEOF_WCHAR_T__ 4
// MIPS32EL:#define __SIZEOF_WINT_T__ 4
+// MIPS32EL:#define __SIZE_MAX__ 4294967295U
// MIPS32EL:#define __SIZE_TYPE__ unsigned int
// MIPS32EL:#define __SIZE_WIDTH__ 32
// MIPS32EL:#define __UINTMAX_TYPE__ long long unsigned int
@@ -988,6 +995,7 @@
// MIPS64BE:#define __SIZEOF_SIZE_T__ 8
// MIPS64BE:#define __SIZEOF_WCHAR_T__ 4
// MIPS64BE:#define __SIZEOF_WINT_T__ 4
+// MIPS64BE:#define __SIZE_MAX__ 18446744073709551615UL
// MIPS64BE:#define __SIZE_TYPE__ long unsigned int
// MIPS64BE:#define __SIZE_WIDTH__ 64
// MIPS64BE:#define __UINTMAX_TYPE__ long long unsigned int
@@ -1103,6 +1111,7 @@
// MIPS64EL:#define __SIZEOF_SIZE_T__ 8
// MIPS64EL:#define __SIZEOF_WCHAR_T__ 4
// MIPS64EL:#define __SIZEOF_WINT_T__ 4
+// MIPS64EL:#define __SIZE_MAX__ 18446744073709551615UL
// MIPS64EL:#define __SIZE_TYPE__ long unsigned int
// MIPS64EL:#define __SIZE_WIDTH__ 64
// MIPS64EL:#define __UINTMAX_TYPE__ long long unsigned int
@@ -1249,6 +1258,7 @@
// MSP430:#define __SIZEOF_SIZE_T__ 2
// MSP430:#define __SIZEOF_WCHAR_T__ 2
// MSP430:#define __SIZEOF_WINT_T__ 2
+// MSP430:#define __SIZE_MAX__ 65535U
// MSP430:#define __SIZE_TYPE__ unsigned int
// MSP430:#define __SIZE_WIDTH__ 16
// MSP430:#define __UINTMAX_TYPE__ long unsigned int
@@ -1346,6 +1356,7 @@
// NVPTX32:#define __SIZEOF_SIZE_T__ 4
// NVPTX32:#define __SIZEOF_WCHAR_T__ 4
// NVPTX32:#define __SIZEOF_WINT_T__ 4
+// NVPTX32:#define __SIZE_MAX__ 4294967295U
// NVPTX32:#define __SIZE_TYPE__ unsigned int
// NVPTX32:#define __SIZE_WIDTH__ 32
// NVPTX32:#define __UINTMAX_TYPE__ long long unsigned int
@@ -1442,6 +1453,7 @@
// NVPTX64:#define __SIZEOF_SIZE_T__ 8
// NVPTX64:#define __SIZEOF_WCHAR_T__ 4
// NVPTX64:#define __SIZEOF_WINT_T__ 4
+// NVPTX64:#define __SIZE_MAX__ 18446744073709551615UL
// NVPTX64:#define __SIZE_TYPE__ long long unsigned int
// NVPTX64:#define __SIZE_WIDTH__ 64
// NVPTX64:#define __UINTMAX_TYPE__ long long unsigned int
@@ -1543,6 +1555,7 @@
// PPC603E:#define __SIZEOF_SIZE_T__ 4
// PPC603E:#define __SIZEOF_WCHAR_T__ 4
// PPC603E:#define __SIZEOF_WINT_T__ 4
+// PPC603E:#define __SIZE_MAX__ 4294967295U
// PPC603E:#define __SIZE_TYPE__ long unsigned int
// PPC603E:#define __SIZE_WIDTH__ 32
// PPC603E:#define __UINTMAX_TYPE__ long long unsigned int
@@ -1651,6 +1664,7 @@
// PPC64:#define __SIZEOF_SIZE_T__ 8
// PPC64:#define __SIZEOF_WCHAR_T__ 4
// PPC64:#define __SIZEOF_WINT_T__ 4
+// PPC64:#define __SIZE_MAX__ 18446744073709551615UL
// PPC64:#define __SIZE_TYPE__ long unsigned int
// PPC64:#define __SIZE_WIDTH__ 64
// PPC64:#define __UINTMAX_TYPE__ long unsigned int
@@ -1663,6 +1677,166 @@
// PPC64:#define __ppc64__ 1
// PPC64:#define __ppc__ 1
//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu a2q -fno-signed-char < /dev/null | FileCheck -check-prefix PPCA2Q %s
+//
+// PPCA2Q:#define _ARCH_A2 1
+// PPCA2Q:#define _ARCH_A2Q 1
+// PPCA2Q:#define _ARCH_PPC 1
+// PPCA2Q:#define _ARCH_PPC64 1
+// PPCA2Q:#define _ARCH_QP 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-bgq-linux -fno-signed-char < /dev/null | FileCheck -check-prefix PPCBGQ %s
+//
+// PPCBGQ:#define __THW_BLUEGENE__ 1
+// PPCBGQ:#define __TOS_BGQ__ 1
+// PPCBGQ:#define __bg__ 1
+// PPCBGQ:#define __bgq__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu 630 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC630 %s
+//
+// PPC630:#define _ARCH_630 1
+// PPC630:#define _ARCH_PPC 1
+// PPC630:#define _ARCH_PPC64 1
+// PPC630:#define _ARCH_PPCGR 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr3 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPWR3 %s
+//
+// PPCPWR3:#define _ARCH_PPC 1
+// PPCPWR3:#define _ARCH_PPC64 1
+// PPCPWR3:#define _ARCH_PPCGR 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power3 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPOWER3 %s
+//
+// PPCPOWER3:#define _ARCH_PPC 1
+// PPCPOWER3:#define _ARCH_PPC64 1
+// PPCPOWER3:#define _ARCH_PPCGR 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr4 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPWR4 %s
+//
+// PPCPWR4:#define _ARCH_PPC 1
+// PPCPWR4:#define _ARCH_PPC64 1
+// PPCPWR4:#define _ARCH_PPCGR 1
+// PPCPWR4:#define _ARCH_PPCSQ 1
+// PPCPWR4:#define _ARCH_PWR4 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power4 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPOWER4 %s
+//
+// PPCPOWER4:#define _ARCH_PPC 1
+// PPCPOWER4:#define _ARCH_PPC64 1
+// PPCPOWER4:#define _ARCH_PPCGR 1
+// PPCPOWER4:#define _ARCH_PPCSQ 1
+// PPCPOWER4:#define _ARCH_PWR4 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr5 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPWR5 %s
+//
+// PPCPWR5:#define _ARCH_PPC 1
+// PPCPWR5:#define _ARCH_PPC64 1
+// PPCPWR5:#define _ARCH_PPCGR 1
+// PPCPWR5:#define _ARCH_PPCSQ 1
+// PPCPWR5:#define _ARCH_PWR4 1
+// PPCPWR5:#define _ARCH_PWR5 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power5 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPOWER5 %s
+//
+// PPCPOWER5:#define _ARCH_PPC 1
+// PPCPOWER5:#define _ARCH_PPC64 1
+// PPCPOWER5:#define _ARCH_PPCGR 1
+// PPCPOWER5:#define _ARCH_PPCSQ 1
+// PPCPOWER5:#define _ARCH_PWR4 1
+// PPCPOWER5:#define _ARCH_PWR5 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr5x -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPWR5X %s
+//
+// PPCPWR5X:#define _ARCH_PPC 1
+// PPCPWR5X:#define _ARCH_PPC64 1
+// PPCPWR5X:#define _ARCH_PPCGR 1
+// PPCPWR5X:#define _ARCH_PPCSQ 1
+// PPCPWR5X:#define _ARCH_PWR4 1
+// PPCPWR5X:#define _ARCH_PWR5 1
+// PPCPWR5X:#define _ARCH_PWR5X 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power5x -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPOWER5X %s
+//
+// PPCPOWER5X:#define _ARCH_PPC 1
+// PPCPOWER5X:#define _ARCH_PPC64 1
+// PPCPOWER5X:#define _ARCH_PPCGR 1
+// PPCPOWER5X:#define _ARCH_PPCSQ 1
+// PPCPOWER5X:#define _ARCH_PWR4 1
+// PPCPOWER5X:#define _ARCH_PWR5 1
+// PPCPOWER5X:#define _ARCH_PWR5X 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr6 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPWR6 %s
+//
+// PPCPWR6:#define _ARCH_PPC 1
+// PPCPWR6:#define _ARCH_PPC64 1
+// PPCPWR6:#define _ARCH_PPCGR 1
+// PPCPWR6:#define _ARCH_PPCSQ 1
+// PPCPWR6:#define _ARCH_PWR4 1
+// PPCPWR6:#define _ARCH_PWR5 1
+// PPCPWR6:#define _ARCH_PWR5X 1
+// PPCPWR6:#define _ARCH_PWR6 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power6 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPOWER6 %s
+//
+// PPCPOWER6:#define _ARCH_PPC 1
+// PPCPOWER6:#define _ARCH_PPC64 1
+// PPCPOWER6:#define _ARCH_PPCGR 1
+// PPCPOWER6:#define _ARCH_PPCSQ 1
+// PPCPOWER6:#define _ARCH_PWR4 1
+// PPCPOWER6:#define _ARCH_PWR5 1
+// PPCPOWER6:#define _ARCH_PWR5X 1
+// PPCPOWER6:#define _ARCH_PWR6 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr6x -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPWR6X %s
+//
+// PPCPWR6X:#define _ARCH_PPC 1
+// PPCPWR6X:#define _ARCH_PPC64 1
+// PPCPWR6X:#define _ARCH_PPCGR 1
+// PPCPWR6X:#define _ARCH_PPCSQ 1
+// PPCPWR6X:#define _ARCH_PWR4 1
+// PPCPWR6X:#define _ARCH_PWR5 1
+// PPCPWR6X:#define _ARCH_PWR5X 1
+// PPCPWR6X:#define _ARCH_PWR6 1
+// PPCPWR6X:#define _ARCH_PWR6X 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power6x -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPOWER6X %s
+//
+// PPCPOWER6X:#define _ARCH_PPC 1
+// PPCPOWER6X:#define _ARCH_PPC64 1
+// PPCPOWER6X:#define _ARCH_PPCGR 1
+// PPCPOWER6X:#define _ARCH_PPCSQ 1
+// PPCPOWER6X:#define _ARCH_PWR4 1
+// PPCPOWER6X:#define _ARCH_PWR5 1
+// PPCPOWER6X:#define _ARCH_PWR5X 1
+// PPCPOWER6X:#define _ARCH_PWR6 1
+// PPCPOWER6X:#define _ARCH_PWR6X 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPWR7 %s
+//
+// PPCPWR7:#define _ARCH_PPC 1
+// PPCPWR7:#define _ARCH_PPC64 1
+// PPCPWR7:#define _ARCH_PPCGR 1
+// PPCPWR7:#define _ARCH_PPCSQ 1
+// PPCPWR7:#define _ARCH_PWR4 1
+// PPCPWR7:#define _ARCH_PWR5 1
+// PPCPWR7:#define _ARCH_PWR5X 1
+// PPCPWR7:#define _ARCH_PWR6 1
+// PPCPWR7:#define _ARCH_PWR6X 1
+// PPCPWR7:#define _ARCH_PWR7 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power7 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPOWER7 %s
+//
+// PPCPOWER7:#define _ARCH_PPC 1
+// PPCPOWER7:#define _ARCH_PPC64 1
+// PPCPOWER7:#define _ARCH_PPCGR 1
+// PPCPOWER7:#define _ARCH_PPCSQ 1
+// PPCPOWER7:#define _ARCH_PWR4 1
+// PPCPOWER7:#define _ARCH_PWR5 1
+// PPCPOWER7:#define _ARCH_PWR5X 1
+// PPCPOWER7:#define _ARCH_PWR6 1
+// PPCPOWER7:#define _ARCH_PWR6X 1
+// PPCPOWER7:#define _ARCH_PWR7 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64-LINUX %s
//
// PPC64-LINUX:#define _ARCH_PPC 1
@@ -1753,6 +1927,7 @@
// PPC64-LINUX:#define __SIZEOF_SIZE_T__ 8
// PPC64-LINUX:#define __SIZEOF_WCHAR_T__ 4
// PPC64-LINUX:#define __SIZEOF_WINT_T__ 4
+// PPC64-LINUX:#define __SIZE_MAX__ 18446744073709551615UL
// PPC64-LINUX:#define __SIZE_TYPE__ long unsigned int
// PPC64-LINUX:#define __SIZE_WIDTH__ 64
// PPC64-LINUX:#define __UINTMAX_TYPE__ long unsigned int
@@ -1857,6 +2032,7 @@
// PPC:#define __SIZEOF_SIZE_T__ 4
// PPC:#define __SIZEOF_WCHAR_T__ 4
// PPC:#define __SIZEOF_WINT_T__ 4
+// PPC:#define __SIZE_MAX__ 4294967295U
// PPC:#define __SIZE_TYPE__ long unsigned int
// PPC:#define __SIZE_WIDTH__ 32
// PPC:#define __UINTMAX_TYPE__ long long unsigned int
@@ -1957,6 +2133,7 @@
// PPC-LINUX:#define __SIZEOF_SIZE_T__ 4
// PPC-LINUX:#define __SIZEOF_WCHAR_T__ 4
// PPC-LINUX:#define __SIZEOF_WINT_T__ 4
+// PPC-LINUX:#define __SIZE_MAX__ 4294967295U
// PPC-LINUX:#define __SIZE_TYPE__ unsigned int
// PPC-LINUX:#define __SIZE_WIDTH__ 32
// PPC-LINUX:#define __UINTMAX_TYPE__ long long unsigned int
@@ -2052,6 +2229,7 @@
// SPARC:#define __SIZEOF_SIZE_T__ 4
// SPARC:#define __SIZEOF_WCHAR_T__ 4
// SPARC:#define __SIZEOF_WINT_T__ 4
+// SPARC:#define __SIZE_MAX__ 4294967295U
// SPARC:#define __SIZE_TYPE__ long unsigned int
// SPARC:#define __SIZE_WIDTH__ 32
// SPARC:#define __UINTMAX_TYPE__ long long unsigned int
@@ -2146,6 +2324,7 @@
// TCE:#define __SIZEOF_SIZE_T__ 4
// TCE:#define __SIZEOF_WCHAR_T__ 4
// TCE:#define __SIZEOF_WINT_T__ 4
+// TCE:#define __SIZE_MAX__ 4294967295U
// TCE:#define __SIZE_TYPE__ unsigned int
// TCE:#define __SIZE_WIDTH__ 32
// TCE:#define __TCE_V1__ 1
@@ -2246,6 +2425,7 @@
// X86_64:#define __SIZEOF_SIZE_T__ 8
// X86_64:#define __SIZEOF_WCHAR_T__ 4
// X86_64:#define __SIZEOF_WINT_T__ 4
+// X86_64:#define __SIZE_MAX__ 18446744073709551615UL
// X86_64:#define __SIZE_TYPE__ long unsigned int
// X86_64:#define __SIZE_WIDTH__ 64
// X86_64:#define __SSE2_MATH__ 1
@@ -2349,6 +2529,7 @@
// X86_64-LINUX:#define __SIZEOF_SIZE_T__ 8
// X86_64-LINUX:#define __SIZEOF_WCHAR_T__ 4
// X86_64-LINUX:#define __SIZEOF_WINT_T__ 4
+// X86_64-LINUX:#define __SIZE_MAX__ 18446744073709551615UL
// X86_64-LINUX:#define __SIZE_TYPE__ long unsigned int
// X86_64-LINUX:#define __SIZE_WIDTH__ 64
// X86_64-LINUX:#define __SSE2_MATH__ 1
diff --git a/test/Preprocessor/invalid-__has_warning1.c b/test/Preprocessor/invalid-__has_warning1.c
new file mode 100644
index 0000000..b6a0b2e
--- /dev/null
+++ b/test/Preprocessor/invalid-__has_warning1.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -verify %s
+
+// These must be the last lines in this test.
+// expected-error@+1{{expected string literal}} expected-error@+1 2{{expected}}
+int i = __has_warning(
diff --git a/test/Preprocessor/invalid-__has_warning2.c b/test/Preprocessor/invalid-__has_warning2.c
new file mode 100644
index 0000000..8aba530
--- /dev/null
+++ b/test/Preprocessor/invalid-__has_warning2.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -verify %s
+
+// These must be the last lines in this test.
+// expected-error@+1{{expected string literal}} expected-error@+1{{expected}}
+int i = __has_warning();
diff --git a/test/Preprocessor/iwithprefix.c b/test/Preprocessor/iwithprefix.c
new file mode 100644
index 0000000..c11f36e
--- /dev/null
+++ b/test/Preprocessor/iwithprefix.c
@@ -0,0 +1,17 @@
+// Check that -iwithprefix falls into the "after" search list.
+//
+// RUN: rm -rf %t.tmps
+// RUN: mkdir -p %t.tmps/first %t.tmps/second
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -iprefix %t.tmps/ -iwithprefix second \
+// RUN: -isystem %t.tmps/first -v 2> %t.out
+// RUN: cat %t.out
+// RUN: FileCheck < %t.out %s
+
+// CHECK: #include <...> search starts here:
+// CHECK: {{.*}}.tmps/first
+// CHECK: /lib/clang/{{[.0-9]+}}/include
+// CHECK: {{.*}}.tmps/second
+// CHECK-NOT: {{.*}}.tmps
+
+
diff --git a/test/Preprocessor/line-directive-output.c b/test/Preprocessor/line-directive-output.c
index 290703a..bd3ea94 100644
--- a/test/Preprocessor/line-directive-output.c
+++ b/test/Preprocessor/line-directive-output.c
@@ -2,6 +2,10 @@
// PR6101
int a;
// CHECK: # 1 "{{.*}}line-directive-output.c"
+
+// Check that we do not emit an enter marker for the main file.
+// CHECK-NOT: # 1 "{{.*}}line-directive-output.c" 1
+
// CHECK: int a;
// CHECK-NEXT: # 50 "{{.*}}line-directive-output.c"
diff --git a/test/Preprocessor/macro-multiline.c b/test/Preprocessor/macro-multiline.c.ignoreme
index df7c40a..df7c40a 100644
--- a/test/Preprocessor/macro-multiline.c
+++ b/test/Preprocessor/macro-multiline.c.ignoreme
diff --git a/test/Preprocessor/macro_arg_slocentry_merge.c b/test/Preprocessor/macro_arg_slocentry_merge.c
new file mode 100644
index 0000000..9ab385f
--- /dev/null
+++ b/test/Preprocessor/macro_arg_slocentry_merge.c
@@ -0,0 +1,7 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+#include "macro_arg_slocentry_merge.h"
+
+// CHECK: macro_arg_slocentry_merge.h:7:19: error: unknown type name 'win'
+// CHECK: macro_arg_slocentry_merge.h:5:16: note: expanded from macro 'WINDOW'
+// CHECK: macro_arg_slocentry_merge.h:6:18: note: expanded from macro 'P_'
diff --git a/test/Preprocessor/macro_arg_slocentry_merge.h b/test/Preprocessor/macro_arg_slocentry_merge.h
new file mode 100644
index 0000000..62595b7
--- /dev/null
+++ b/test/Preprocessor/macro_arg_slocentry_merge.h
@@ -0,0 +1,7 @@
+
+
+
+
+#define WINDOW win
+#define P_(args) args
+extern void f P_((WINDOW win));
diff --git a/test/Preprocessor/macro_expand.c b/test/Preprocessor/macro_expand.c
index 4dc0357..cf98a2c 100644
--- a/test/Preprocessor/macro_expand.c
+++ b/test/Preprocessor/macro_expand.c
@@ -1,11 +1,10 @@
-// RUN: %clang_cc1 -E %s | grep '^A: Y$'
-// RUN: %clang_cc1 -E %s | grep '^B: f()$'
-// RUN: %clang_cc1 -E %s | grep '^C: for()$'
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
#define X() Y
#define Y() X
A: X()()()
+// CHECK: {{^}}A: Y{{$}}
// PR3927
#define f(x) h(x
@@ -14,6 +13,9 @@ A: X()()()
B: f(f))
C: for(for))
+// CHECK: {{^}}B: f(){{$}}
+// CHECK: {{^}}C: for(){{$}}
+
// rdar://6880648
#define f(x,y...) y
f()
diff --git a/test/Preprocessor/macro_expandloc.c b/test/Preprocessor/macro_expandloc.c
index f466013..3b9eb5f 100644
--- a/test/Preprocessor/macro_expandloc.c
+++ b/test/Preprocessor/macro_expandloc.c
@@ -1,6 +1,13 @@
-// RUN: %clang_cc1 %s -E 2>&1 | grep '#include'
+// RUN: %clang_cc1 -E -verify %s
#define FOO 1
// The error message should be on the #include line, not the 1.
+
+// expected-error@+1 {{expected "FILENAME" or <FILENAME>}}
#include FOO
+#define BAR BAZ
+
+// expected-error@+1 {{expected "FILENAME" or <FILENAME>}}
+#include BAR
+
diff --git a/test/Preprocessor/macro_expandloc2.c b/test/Preprocessor/macro_expandloc2.c
deleted file mode 100644
index 4aa7dfe..0000000
--- a/test/Preprocessor/macro_expandloc2.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang_cc1 %s -E 2>&1 | grep '#include'
-#define FOO BAR
-
-// The error message should be on the #include line, not the 1.
-#include FOO
-
diff --git a/test/Preprocessor/macro_fn.c b/test/Preprocessor/macro_fn.c
index f93d52c..fcdb90a 100644
--- a/test/Preprocessor/macro_fn.c
+++ b/test/Preprocessor/macro_fn.c
@@ -1,9 +1,9 @@
/* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify
*/
/* PR3937 */
-#define zero() 0
-#define one(x) 0
-#define two(x, y) 0
+#define zero() 0 /* expected-note 2 {{defined here}} */
+#define one(x) 0 /* expected-note 2 {{defined here}} */
+#define two(x, y) 0 /* expected-note 4 {{defined here}} */
#define zero_dot(...) 0 /* expected-warning {{variadic macros are a C99 feature}} */
#define one_dot(x, ...) 0 /* expected-warning {{variadic macros are a C99 feature}} expected-note 2{{macro 'one_dot' defined here}} */
@@ -44,3 +44,9 @@ one_dot() /* empty first argument, elided ...: expected-warning {{must specify
#define E() (i == 0)
#if E
#endif
+
+
+/* <rdar://problem/12292192> */
+#define NSAssert(condition, desc, ...) /* expected-warning {{variadic macros are a C99 feature}} */ \
+ SomeComplicatedStuff((desc), ##__VA_ARGS__) /* expected-warning {{token pasting of ',' and __VA_ARGS__ is a GNU extension}} */
+NSAssert(somecond, somedesc)
diff --git a/test/Preprocessor/macro_misc.c b/test/Preprocessor/macro_misc.c
index 53d9982..3feaa21 100644
--- a/test/Preprocessor/macro_misc.c
+++ b/test/Preprocessor/macro_misc.c
@@ -21,3 +21,17 @@
#define FUNC_LIKE3(a) ( a) // expected-note {{previous definition is here}}
#define FUNC_LIKE3(a) (a) // expected-warning {{'FUNC_LIKE3' macro redefined}}
+// RUN: %clang_cc1 -fms-extensions -DMS_EXT %s -Eonly -verify
+#ifndef MS_EXT
+// This should under C99.
+#define FUNC_LIKE4(a,b) (a+b) // expected-note {{previous definition is here}}
+#define FUNC_LIKE4(x,y) (x+y) // expected-warning {{'FUNC_LIKE4' macro redefined}}
+#else
+// This shouldn't under MS extensions.
+#define FUNC_LIKE4(a,b) (a+b)
+#define FUNC_LIKE4(x,y) (x+y)
+
+// This should.
+#define FUNC_LIKE5(a,b) (a+b) // expected-note {{previous definition is here}}
+#define FUNC_LIKE5(x,y) (y+x) // expected-warning {{'FUNC_LIKE5' macro redefined}}
+#endif
diff --git a/test/Preprocessor/macro_rescan.c b/test/Preprocessor/macro_rescan.c
index 3a38548..83a1975 100644
--- a/test/Preprocessor/macro_rescan.c
+++ b/test/Preprocessor/macro_rescan.c
@@ -1,9 +1,11 @@
-// RUN: %clang_cc1 -E %s | grep 'ei_1 = (17 +1);'
-// RUN: %clang_cc1 -E %s | grep 'ei_2 = (M1)(17);'
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
-#define M1(a) (a+1)
-#define M2(b) b
+#define M1(a) (a+1)
+#define M2(b) b
-int ei_1 = M2(M1)(17); /* becomes int ei_1 = (17+1); */
-int ei_2 = (M2(M1))(17); /* becomes int ei_2 = (M1)(17); */
+int ei_1 = M2(M1)(17);
+// CHECK: {{^}}int ei_1 = (17 +1);{{$}}
+
+int ei_2 = (M2(M1))(17);
+// CHECK: {{^}}int ei_2 = (M1)(17);{{$}}
diff --git a/test/Preprocessor/macro_space.c b/test/Preprocessor/macro_space.c
index 49a9a0f..8a47a3b 100644
--- a/test/Preprocessor/macro_space.c
+++ b/test/Preprocessor/macro_space.c
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 %s -E | grep '! ,'
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
#define XX
! XX,
+// CHECK: {{^}}! ,{{$}}
diff --git a/test/Preprocessor/macro_variadic.cl b/test/Preprocessor/macro_variadic.cl
new file mode 100644
index 0000000..e4c5566
--- /dev/null
+++ b/test/Preprocessor/macro_variadic.cl
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -verify %s
+
+#define X(...) 1 // expected-error {{variadic macros not supported in OpenCL}}
diff --git a/test/Preprocessor/microsoft-import.c b/test/Preprocessor/microsoft-import.c
index 8835c7a..2fc58bc 100644
--- a/test/Preprocessor/microsoft-import.c
+++ b/test/Preprocessor/microsoft-import.c
@@ -1,17 +1,12 @@
-// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:100:2: error: #import of type library is an unsupported Microsoft feature'
-// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:200:2: error: #import of type library is an unsupported Microsoft feature'
-// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:300:2: error: #import of type library is an unsupported Microsoft feature'
+// RUN: %clang_cc1 -E -verify -fms-compatibility %s
-#line 100 "doh.c"
#import "pp-record.h" // expected-error {{#import of type library is an unsupported Microsoft feature}}
// Test attributes
-#line 200 "doh.c"
#import "pp-record.h" no_namespace, auto_rename // expected-error {{#import of type library is an unsupported Microsoft feature}}
-// This will also fire the "#import of type library is an unsupported Microsoft feature"
-// error, but we can't use -verify because there's no way to put the comment on the proper line
-#line 300 "doh.c"
#import "pp-record.h" no_namespace \
auto_rename \
auto_search
+// expected-error@-3 {{#import of type library is an unsupported Microsoft feature}}
+
diff --git a/test/Preprocessor/output_paste_avoid.c b/test/Preprocessor/output_paste_avoid.c
deleted file mode 100644
index 8e4f3a4..0000000
--- a/test/Preprocessor/output_paste_avoid.c
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 -E %s -o - | FileCheck -strict-whitespace %s
-
-
-#define y(a) ..a
-A: y(.)
-// This should print as ".. ." to avoid turning into ...
-// CHECK: A: .. .
-
-#define X 0 .. 1
-B: X
-// CHECK: B: 0 .. 1
-
-#define DOT .
-C: ..DOT
-// CHECK: C: .. .
-
-
-#define PLUS +
-#define EMPTY
-#define f(x) =x=
-D: +PLUS -EMPTY- PLUS+ f(=)
-// CHECK: D: + + - - + + = = =
-
-
-#define test(x) L#x
-E: test(str)
-// Should expand to L "str" not L"str"
-// CHECK: E: L "str"
-
-// Should avoid producing >>=.
-#define equal =
-F: >>equal
-// CHECK: F: >> =
diff --git a/test/Preprocessor/output_paste_avoid.cpp b/test/Preprocessor/output_paste_avoid.cpp
new file mode 100644
index 0000000..689d966
--- /dev/null
+++ b/test/Preprocessor/output_paste_avoid.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -E -std=c++11 %s -o - | FileCheck -strict-whitespace %s
+
+
+#define y(a) ..a
+A: y(.)
+// This should print as ".. ." to avoid turning into ...
+// CHECK: A: .. .
+
+#define X 0 .. 1
+B: X
+// CHECK: B: 0 .. 1
+
+#define DOT .
+C: ..DOT
+// CHECK: C: .. .
+
+
+#define PLUS +
+#define EMPTY
+#define f(x) =x=
+D: +PLUS -EMPTY- PLUS+ f(=)
+// CHECK: D: + + - - + + = = =
+
+
+#define test(x) L#x
+E: test(str)
+// Should expand to L "str" not L"str"
+// CHECK: E: L "str"
+
+// Should avoid producing >>=.
+#define equal =
+F: >>equal
+// CHECK: F: >> =
+
+// Make sure we don't introduce spaces in the guid because we try to avoid
+// pasting '-' to a numeric constant.
+#define TYPEDEF(guid) typedef [uuid(guid)]
+TYPEDEF(66504301-BE0F-101A-8BBB-00AA00300CAB) long OLE_COLOR;
+// CHECK: typedef [uuid(66504301-BE0F-101A-8BBB-00AA00300CAB)] long OLE_COLOR;
+
+// Be careful with UD-suffixes.
+#define StrSuffix() "abc"_suffix
+#define IntSuffix() 123_suffix
+UD: StrSuffix()ident
+UD: IntSuffix()ident
+// CHECK: UD: "abc"_suffix ident
+// CHECK: UD: 123_suffix ident
diff --git a/test/Preprocessor/pp-record.c b/test/Preprocessor/pp-record.c
index dd958d0..48000ed 100644
--- a/test/Preprocessor/pp-record.c
+++ b/test/Preprocessor/pp-record.c
@@ -21,3 +21,14 @@ FNM(
int b;
#endif
)
+
+#define M1 c
+#define M2 int
+#define FM2(x,y) y x
+FM2(M1, M2);
+
+#define FM3(x) x
+FM3(
+#define M3 int x2
+)
+M3;
diff --git a/test/Preprocessor/pragma_diagnostic.c b/test/Preprocessor/pragma_diagnostic.c
index 818f02f..e8a67ab 100644
--- a/test/Preprocessor/pragma_diagnostic.c
+++ b/test/Preprocessor/pragma_diagnostic.c
@@ -23,7 +23,7 @@
#define foo error
#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}}
+#pragma GCC diagnostic error 42 // expected-error {{expected string literal in pragma diagnostic}}
#pragma GCC diagnostic error "-Wundef" 42 // expected-warning {{unexpected token in pragma diagnostic}}
#pragma GCC diagnostic error "invalid-name" // expected-warning {{pragma diagnostic expected option name (e.g. "-Wundef")}}
diff --git a/test/Preprocessor/pragma_microsoft.c b/test/Preprocessor/pragma_microsoft.c
index e461c70..c0ddf74 100644
--- a/test/Preprocessor/pragma_microsoft.c
+++ b/test/Preprocessor/pragma_microsoft.c
@@ -11,7 +11,7 @@
#pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )
#pragma comment(foo) // expected-error {{unknown kind of pragma comment}}
-#pragma comment(compiler,) // expected-error {{pragma comment requires}}
+#pragma comment(compiler,) // expected-error {{expected string literal in pragma comment}}
#define foo compiler
#pragma comment(foo) // macro expand kind.
#pragma comment(foo) x // expected-error {{pragma comment requires}}
@@ -26,7 +26,7 @@ __pragma(comment(linker," bar=" BAR))
#define MACRO_WITH__PRAGMA { \
__pragma(warning(push)); \
__pragma(warning(disable: 10000)); \
- 2+2; \
+ 1 + (2 > 3) ? 4 : 5; \
__pragma(warning(pop)); \
}
@@ -36,7 +36,8 @@ void f()
// If we ever actually *support* __pragma(warning(disable: x)),
// this warning should go away.
- MACRO_WITH__PRAGMA // expected-warning {{expression result unused}}
+ MACRO_WITH__PRAGMA // expected-warning {{lower precedence}} \
+ // expected-note 2 {{place parentheses}}
}
diff --git a/test/Preprocessor/pragma_unknown.c b/test/Preprocessor/pragma_unknown.c
index 2586754..5578ce5 100644
--- a/test/Preprocessor/pragma_unknown.c
+++ b/test/Preprocessor/pragma_unknown.c
@@ -1,9 +1,10 @@
-// RUN: %clang_cc1 -E %s | grep '#pragma foo bar'
// RUN: %clang_cc1 -fsyntax-only -Wunknown-pragmas -verify %s
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
// GCC doesn't expand macro args for unrecognized pragmas.
#define bar xX
#pragma foo bar // expected-warning {{unknown pragma ignored}}
+// CHECK: {{^}}#pragma foo bar{{$}}
#pragma STDC FP_CONTRACT ON
#pragma STDC FP_CONTRACT OFF
diff --git a/test/Preprocessor/predefined-arch-macros.c b/test/Preprocessor/predefined-arch-macros.c
index 719f945..680f39a 100644
--- a/test/Preprocessor/predefined-arch-macros.c
+++ b/test/Preprocessor/predefined-arch-macros.c
@@ -464,6 +464,7 @@
// RUN: | FileCheck %s -check-prefix=CHECK_CORE_AVX_I_M32
// CHECK_CORE_AVX_I_M32: #define __AES__ 1
// CHECK_CORE_AVX_I_M32: #define __AVX__ 1
+// CHECK_CORE_AVX_I_M32: #define __F16C__ 1
// CHECK_CORE_AVX_I_M32: #define __MMX__ 1
// CHECK_CORE_AVX_I_M32: #define __PCLMUL__ 1
// CHECK_CORE_AVX_I_M32: #define __RDRND__ 1
@@ -484,6 +485,7 @@
// RUN: | FileCheck %s -check-prefix=CHECK_CORE_AVX_I_M64
// CHECK_CORE_AVX_I_M64: #define __AES__ 1
// CHECK_CORE_AVX_I_M64: #define __AVX__ 1
+// CHECK_CORE_AVX_I_M64: #define __F16C__ 1
// CHECK_CORE_AVX_I_M64: #define __MMX__ 1
// CHECK_CORE_AVX_I_M64: #define __PCLMUL__ 1
// CHECK_CORE_AVX_I_M64: #define __RDRND__ 1
@@ -510,6 +512,7 @@
// CHECK_CORE_AVX2_M32: #define __AVX__ 1
// CHECK_CORE_AVX2_M32: #define __BMI2__ 1
// CHECK_CORE_AVX2_M32: #define __BMI__ 1
+// CHECK_CORE_AVX2_M32: #define __F16C__ 1
// CHECK_CORE_AVX2_M32: #define __FMA__ 1
// CHECK_CORE_AVX2_M32: #define __LZCNT__ 1
// CHECK_CORE_AVX2_M32: #define __MMX__ 1
@@ -536,6 +539,7 @@
// CHECK_CORE_AVX2_M64: #define __AVX__ 1
// CHECK_CORE_AVX2_M64: #define __BMI2__ 1
// CHECK_CORE_AVX2_M64: #define __BMI__ 1
+// CHECK_CORE_AVX2_M64: #define __F16C__ 1
// CHECK_CORE_AVX2_M64: #define __FMA__ 1
// CHECK_CORE_AVX2_M64: #define __LZCNT__ 1
// CHECK_CORE_AVX2_M64: #define __MMX__ 1
@@ -1008,12 +1012,33 @@
// CHECK_ATHLON_FX_M64: #define __tune_k8__ 1
// CHECK_ATHLON_FX_M64: #define __x86_64 1
// CHECK_ATHLON_FX_M64: #define __x86_64__ 1
+// RUN: %clang -march=amdfam10 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: | FileCheck %s -check-prefix=CHECK_AMDFAM10_M32
+// CHECK_AMDFAM10_M32: #define __3dNOW_A__ 1
+// CHECK_AMDFAM10_M32: #define __3dNOW__ 1
+// CHECK_AMDFAM10_M32: #define __LZCNT__ 1
+// CHECK_AMDFAM10_M32: #define __MMX__ 1
+// CHECK_AMDFAM10_M32: #define __POPCNT__ 1
+// CHECK_AMDFAM10_M32: #define __SSE2_MATH__ 1
+// CHECK_AMDFAM10_M32: #define __SSE2__ 1
+// CHECK_AMDFAM10_M32: #define __SSE3__ 1
+// CHECK_AMDFAM10_M32: #define __SSE4A__ 1
+// CHECK_AMDFAM10_M32: #define __SSE_MATH__ 1
+// CHECK_AMDFAM10_M32: #define __SSE__ 1
+// CHECK_AMDFAM10_M32: #define __amdfam10 1
+// CHECK_AMDFAM10_M32: #define __amdfam10__ 1
+// CHECK_AMDFAM10_M32: #define __i386 1
+// CHECK_AMDFAM10_M32: #define __i386__ 1
+// CHECK_AMDFAM10_M32: #define __tune_amdfam10__ 1
// RUN: %clang -march=amdfam10 -m64 -E -dM %s -o - 2>&1 \
// RUN: -target i386-unknown-linux \
// RUN: | FileCheck %s -check-prefix=CHECK_AMDFAM10_M64
// CHECK_AMDFAM10_M64: #define __3dNOW_A__ 1
// CHECK_AMDFAM10_M64: #define __3dNOW__ 1
+// CHECK_AMDFAM10_M64: #define __LZCNT__ 1
// CHECK_AMDFAM10_M64: #define __MMX__ 1
+// CHECK_AMDFAM10_M64: #define __POPCNT__ 1
// CHECK_AMDFAM10_M64: #define __SSE2_MATH__ 1
// CHECK_AMDFAM10_M64: #define __SSE2__ 1
// CHECK_AMDFAM10_M64: #define __SSE3__ 1
@@ -1027,15 +1052,87 @@
// CHECK_AMDFAM10_M64: #define __tune_amdfam10__ 1
// CHECK_AMDFAM10_M64: #define __x86_64 1
// CHECK_AMDFAM10_M64: #define __x86_64__ 1
+// RUN: %clang -march=btver1 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: | FileCheck %s -check-prefix=CHECK_BTVER1_M32
+// CHECK_BTVER1_M32-NOT: #define __3dNOW_A__ 1
+// CHECK_BTVER1_M32-NOT: #define __3dNOW__ 1
+// CHECK_BTVER1_M32: #define __LZCNT__ 1
+// CHECK_BTVER1_M32: #define __MMX__ 1
+// CHECK_BTVER1_M32: #define __POPCNT__ 1
+// CHECK_BTVER1_M32: #define __SSE2_MATH__ 1
+// CHECK_BTVER1_M32: #define __SSE2__ 1
+// CHECK_BTVER1_M32: #define __SSE3__ 1
+// CHECK_BTVER1_M32: #define __SSE4A__ 1
+// CHECK_BTVER1_M32: #define __SSE_MATH__ 1
+// CHECK_BTVER1_M32: #define __SSE__ 1
+// CHECK_BTVER1_M32: #define __SSSE3__ 1
+// CHECK_BTVER1_M32: #define __btver1 1
+// CHECK_BTVER1_M32: #define __btver1__ 1
+// CHECK_BTVER1_M32: #define __i386 1
+// CHECK_BTVER1_M32: #define __i386__ 1
+// CHECK_BTVER1_M32: #define __tune_btver1__ 1
+// RUN: %clang -march=btver1 -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: | FileCheck %s -check-prefix=CHECK_BTVER1_M64
+// CHECK_BTVER1_M64-NOT: #define __3dNOW_A__ 1
+// CHECK_BTVER1_M64-NOT: #define __3dNOW__ 1
+// CHECK_BTVER1_M64: #define __LZCNT__ 1
+// CHECK_BTVER1_M64: #define __MMX__ 1
+// CHECK_BTVER1_M64: #define __POPCNT__ 1
+// CHECK_BTVER1_M64: #define __SSE2_MATH__ 1
+// CHECK_BTVER1_M64: #define __SSE2__ 1
+// CHECK_BTVER1_M64: #define __SSE3__ 1
+// CHECK_BTVER1_M64: #define __SSE4A__ 1
+// CHECK_BTVER1_M64: #define __SSE_MATH__ 1
+// CHECK_BTVER1_M64: #define __SSE__ 1
+// CHECK_BTVER1_M64: #define __SSSE3__ 1
+// CHECK_BTVER1_M64: #define __amd64 1
+// CHECK_BTVER1_M64: #define __amd64__ 1
+// CHECK_BTVER1_M64: #define __btver1 1
+// CHECK_BTVER1_M64: #define __btver1__ 1
+// CHECK_BTVER1_M64: #define __tune_btver1__ 1
+// CHECK_BTVER1_M64: #define __x86_64 1
+// CHECK_BTVER1_M64: #define __x86_64__ 1
+// RUN: %clang -march=bdver1 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: | FileCheck %s -check-prefix=CHECK_BDVER1_M32
+// CHECK_BDVER1_M32-NOT: #define __3dNOW_A__ 1
+// CHECK_BDVER1_M32-NOT: #define __3dNOW__ 1
+// CHECK_BDVER1_M32: #define __AES__ 1
+// CHECK_BDVER1_M32: #define __AVX__ 1
+// CHECK_BDVER1_M32: #define __FMA4__ 1
+// CHECK_BDVER1_M32: #define __LZCNT__ 1
+// CHECK_BDVER1_M32: #define __MMX__ 1
+// CHECK_BDVER1_M32: #define __PCLMUL__ 1
+// CHECK_BDVER1_M32: #define __POPCNT__ 1
+// CHECK_BDVER1_M32: #define __SSE2_MATH__ 1
+// CHECK_BDVER1_M32: #define __SSE2__ 1
+// CHECK_BDVER1_M32: #define __SSE3__ 1
+// CHECK_BDVER1_M32: #define __SSE4A__ 1
+// CHECK_BDVER1_M32: #define __SSE4_1__ 1
+// CHECK_BDVER1_M32: #define __SSE4_2__ 1
+// CHECK_BDVER1_M32: #define __SSE_MATH__ 1
+// CHECK_BDVER1_M32: #define __SSE__ 1
+// CHECK_BDVER1_M32: #define __SSSE3__ 1
+// CHECK_BDVER1_M32: #define __XOP__ 1
+// CHECK_BDVER1_M32: #define __bdver1 1
+// CHECK_BDVER1_M32: #define __bdver1__ 1
+// CHECK_BDVER1_M32: #define __i386 1
+// CHECK_BDVER1_M32: #define __i386__ 1
+// CHECK_BDVER1_M32: #define __tune_bdver1__ 1
// RUN: %clang -march=bdver1 -m64 -E -dM %s -o - 2>&1 \
// RUN: -target i386-unknown-linux \
// RUN: | FileCheck %s -check-prefix=CHECK_BDVER1_M64
-// CHECK_BDVER1_M64: #define __AVX__ 1
// CHECK_BDVER1_M64-NOT: #define __3dNOW_A__ 1
// CHECK_BDVER1_M64-NOT: #define __3dNOW__ 1
+// CHECK_BDVER1_M64: #define __AES__ 1
+// CHECK_BDVER1_M64: #define __AVX__ 1
// CHECK_BDVER1_M64: #define __FMA4__ 1
+// CHECK_BDVER1_M64: #define __LZCNT__ 1
// CHECK_BDVER1_M64: #define __MMX__ 1
// CHECK_BDVER1_M64: #define __PCLMUL__ 1
+// CHECK_BDVER1_M64: #define __POPCNT__ 1
// CHECK_BDVER1_M64: #define __SSE2_MATH__ 1
// CHECK_BDVER1_M64: #define __SSE2__ 1
// CHECK_BDVER1_M64: #define __SSE3__ 1
@@ -1053,5 +1150,67 @@
// CHECK_BDVER1_M64: #define __tune_bdver1__ 1
// CHECK_BDVER1_M64: #define __x86_64 1
// CHECK_BDVER1_M64: #define __x86_64__ 1
+// RUN: %clang -march=bdver2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: | FileCheck %s -check-prefix=CHECK_BDVER2_M32
+// CHECK_BDVER2_M32-NOT: #define __3dNOW_A__ 1
+// CHECK_BDVER2_M32-NOT: #define __3dNOW__ 1
+// CHECK_BDVER2_M32: #define __AES__ 1
+// CHECK_BDVER2_M32: #define __AVX__ 1
+// CHECK_BDVER2_M32: #define __BMI__ 1
+// CHECK_BDVER2_M32: #define __F16C__ 1
+// CHECK_BDVER2_M32: #define __FMA4__ 1
+// CHECK_BDVER2_M32: #define __FMA__ 1
+// CHECK_BDVER2_M32: #define __LZCNT__ 1
+// CHECK_BDVER2_M32: #define __MMX__ 1
+// CHECK_BDVER2_M32: #define __PCLMUL__ 1
+// CHECK_BDVER2_M32: #define __POPCNT__ 1
+// CHECK_BDVER2_M32: #define __SSE2_MATH__ 1
+// CHECK_BDVER2_M32: #define __SSE2__ 1
+// CHECK_BDVER2_M32: #define __SSE3__ 1
+// CHECK_BDVER2_M32: #define __SSE4A__ 1
+// CHECK_BDVER2_M32: #define __SSE4_1__ 1
+// CHECK_BDVER2_M32: #define __SSE4_2__ 1
+// CHECK_BDVER2_M32: #define __SSE_MATH__ 1
+// CHECK_BDVER2_M32: #define __SSE__ 1
+// CHECK_BDVER2_M32: #define __SSSE3__ 1
+// CHECK_BDVER2_M32: #define __XOP__ 1
+// CHECK_BDVER2_M32: #define __bdver2 1
+// CHECK_BDVER2_M32: #define __bdver2__ 1
+// CHECK_BDVER2_M32: #define __i386 1
+// CHECK_BDVER2_M32: #define __i386__ 1
+// CHECK_BDVER2_M32: #define __tune_bdver2__ 1
+// RUN: %clang -march=bdver2 -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: | FileCheck %s -check-prefix=CHECK_BDVER2_M64
+// CHECK_BDVER2_M64-NOT: #define __3dNOW_A__ 1
+// CHECK_BDVER2_M64-NOT: #define __3dNOW__ 1
+// CHECK_BDVER2_M64: #define __AES__ 1
+// CHECK_BDVER2_M64: #define __AVX__ 1
+// CHECK_BDVER2_M64: #define __BMI__ 1
+// CHECK_BDVER2_M64: #define __F16C__ 1
+// CHECK_BDVER2_M64: #define __FMA4__ 1
+// CHECK_BDVER2_M64: #define __FMA__ 1
+// CHECK_BDVER2_M64: #define __LZCNT__ 1
+// CHECK_BDVER2_M64: #define __MMX__ 1
+// CHECK_BDVER2_M64: #define __PCLMUL__ 1
+// CHECK_BDVER2_M64: #define __POPCNT__ 1
+// CHECK_BDVER2_M64: #define __SSE2_MATH__ 1
+// CHECK_BDVER2_M64: #define __SSE2__ 1
+// CHECK_BDVER2_M64: #define __SSE3__ 1
+// CHECK_BDVER2_M64: #define __SSE4A__ 1
+// CHECK_BDVER2_M64: #define __SSE4_1__ 1
+// CHECK_BDVER2_M64: #define __SSE4_2__ 1
+// CHECK_BDVER2_M64: #define __SSE_MATH__ 1
+// CHECK_BDVER2_M64: #define __SSE__ 1
+// CHECK_BDVER2_M64: #define __SSSE3__ 1
+// CHECK_BDVER2_M64: #define __XOP__ 1
+// CHECK_BDVER2_M64: #define __amd64 1
+// CHECK_BDVER2_M64: #define __amd64__ 1
+// CHECK_BDVER2_M64: #define __bdver2 1
+// CHECK_BDVER2_M64: #define __bdver2__ 1
+// CHECK_BDVER2_M64: #define __tune_bdver2__ 1
+// CHECK_BDVER2_M64: #define __x86_64 1
+// CHECK_BDVER2_M64: #define __x86_64__ 1
//
// End X86/GCC/Linux tests ------------------
diff --git a/test/Preprocessor/predefined-macros.c b/test/Preprocessor/predefined-macros.c
index 2c19301..94671f3 100644
--- a/test/Preprocessor/predefined-macros.c
+++ b/test/Preprocessor/predefined-macros.c
@@ -26,3 +26,21 @@
// RUN: %clang_cc1 %s -E -dM -o - \
// RUN: | FileCheck %s --check-prefix=CHECK-FINITE-MATH-FLAG-UNDEFINED
// CHECK-FINITE-MATH-FLAG-UNDEFINED: #define __FINITE_MATH_ONLY__ 0
+//
+// RUN: %clang_cc1 %s -E -dM -o - -triple i686 -target-cpu i386 \
+// RUN: | FileCheck %s --check-prefix=CHECK-SYNC_CAS_I386
+// CHECK-SYNC_CAS_I386-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP
+//
+// RUN: %clang_cc1 %s -E -dM -o - -triple i686 -target-cpu i486 \
+// RUN: | FileCheck %s --check-prefix=CHECK-SYNC_CAS_I486
+// CHECK-SYNC_CAS_I486: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
+// CHECK-SYNC_CAS_I486: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+// CHECK-SYNC_CAS_I486: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+// CHECK-SYNC_CAS_I486-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
+//
+// RUN: %clang_cc1 %s -E -dM -o - -triple i686 -target-cpu i586 \
+// RUN: | FileCheck %s --check-prefix=CHECK-SYNC_CAS_I586
+// CHECK-SYNC_CAS_I586: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
+// CHECK-SYNC_CAS_I586: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+// CHECK-SYNC_CAS_I586: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+// CHECK-SYNC_CAS_I586: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
diff --git a/test/Preprocessor/print_line_count.c b/test/Preprocessor/print_line_count.c
index 6a02b0e..6ada93b 100644
--- a/test/Preprocessor/print_line_count.c
+++ b/test/Preprocessor/print_line_count.c
@@ -1,4 +1,7 @@
-/* RUN: %clang -E -C -P %s | wc -l | grep 4
+/* RUN: %clang -E -C -P %s | FileCheck --strict-whitespace %s
PR2741
comment */
y
+// CHECK: {{^}} comment */{{$}}
+// CHECK-NEXT: {{^}}y{{$}}
+
diff --git a/test/Preprocessor/print_line_include.c b/test/Preprocessor/print_line_include.c
new file mode 100644
index 0000000..d65873c
--- /dev/null
+++ b/test/Preprocessor/print_line_include.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E -P %s | FileCheck %s
+// CHECK: int x;
+// CHECK-NEXT: int x;
+
+#include "print_line_include.h"
+#include "print_line_include.h"
diff --git a/test/Preprocessor/print_line_include.h b/test/Preprocessor/print_line_include.h
new file mode 100644
index 0000000..6d1a0d4
--- /dev/null
+++ b/test/Preprocessor/print_line_include.h
@@ -0,0 +1 @@
+int x;
diff --git a/test/Preprocessor/skipping_unclean.c b/test/Preprocessor/skipping_unclean.c
index 52d1785..ce75b39 100644
--- a/test/Preprocessor/skipping_unclean.c
+++ b/test/Preprocessor/skipping_unclean.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -E %s | grep bark
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
#if 0
blah
@@ -6,4 +6,5 @@ blah
else
bark
#endif
+// CHECK: {{^}}bark{{$}}
diff --git a/test/Preprocessor/stringize_space.c b/test/Preprocessor/stringize_space.c
index 263cff8..2d79d47 100644
--- a/test/Preprocessor/stringize_space.c
+++ b/test/Preprocessor/stringize_space.c
@@ -1,4 +1,14 @@
-// RUN: %clang_cc1 -E %s | grep -- '-"" , - "" , -"" , - ""'
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
#define A(b) -#b , - #b , -# b , - # b
A()
+
+// CHECK: {{^}}-"" , - "" , -"" , - ""{{$}}
+
+
+#define t(x) #x
+t(a
+c)
+
+// CHECK: {{^}}"a c"{{$}}
+
diff --git a/test/Preprocessor/stringize_space2.c b/test/Preprocessor/stringize_space2.c
deleted file mode 100644
index a87d78e..0000000
--- a/test/Preprocessor/stringize_space2.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* RUN: %clang_cc1 -E %s | grep 'a c'
- */
-#define t(x) #x
-t(a
-c)
-
diff --git a/test/Preprocessor/traditional-cpp.c b/test/Preprocessor/traditional-cpp.c
index 5fc9ee3..4c4633e 100644
--- a/test/Preprocessor/traditional-cpp.c
+++ b/test/Preprocessor/traditional-cpp.c
@@ -4,9 +4,87 @@
/*
RUN: %clang_cc1 -traditional-cpp %s -E -o %t
- RUN: FileCheck < %t %s
+ RUN: FileCheck -strict-whitespace < %t %s
+ RUN: %clang_cc1 -traditional-cpp %s -E -C | FileCheck -check-prefix=CHECK-COMMENTS %s
*/
-/* CHECK: foo // bar
+/* -traditional-cpp should eliminate all C89 comments. */
+/* CHECK-NOT: /*
+ * CHECK-COMMENTS: {{^}}/* -traditional-cpp should eliminate all C89 comments. *{{/$}}
+ */
+
+/* CHECK: {{^}}foo // bar{{$}}
*/
foo // bar
+
+
+/* The lines in this file contain hard tab characters and trailing whitespace;
+ * do not change them! */
+
+/* CHECK: {{^}} indented!{{$}}
+ * CHECK: {{^}}tab separated values{{$}}
+ */
+ indented!
+tab separated values
+
+#define bracket(x) >>>x<<<
+bracket(| spaces |)
+/* CHECK: {{^}}>>>| spaces |<<<{{$}}
+ */
+
+/* This is still a preprocessing directive. */
+# define foo bar
+foo!
+-
+ foo! foo!
+/* CHECK: {{^}}bar!{{$}}
+ * CHECK: {{^}} bar! bar! {{$}}
+ */
+
+/* Deliberately check a leading newline with spaces on that line. */
+
+# define foo bar
+foo!
+-
+ foo! foo!
+/* CHECK: {{^}}bar!{{$}}
+ * CHECK: {{^}} bar! bar! {{$}}
+ */
+
+/* FIXME: -traditional-cpp should not consider this a preprocessing directive
+ * because the # isn't in the first column.
+ */
+ #define foo2 bar
+foo2!
+/* If this were working, both of these checks would be on.
+ * CHECK-NOT: {{^}} #define foo2 bar{{$}}
+ * CHECK-NOT: {{^}}foo2!{{$}}
+ */
+
+/* FIXME: -traditional-cpp should not homogenize whitespace in macros.
+ */
+#define bracket2(x) >>> x <<<
+bracket2(spaces)
+/* If this were working, this check would be on.
+ * CHECK-NOT: {{^}}>>> spaces <<<{{$}}
+ */
+
+
+/* Check that #if 0 blocks work as expected */
+#if 0
+#error "this is not an error"
+
+#if 1
+a b c in skipped block
+#endif
+
+/* Comments are whitespace too */
+
+#endif
+/* CHECK-NOT: {{^}}a b c in skipped block{{$}}
+ * CHECK-NOT: {{^}}/* Comments are whitespace too
+ */
+
+Preserve URLs: http://clang.llvm.org
+/* CHECK: {{^}}Preserve URLs: http://clang.llvm.org{{$}}
+ */
diff --git a/test/Preprocessor/ucn-allowed-chars.c b/test/Preprocessor/ucn-allowed-chars.c
new file mode 100644
index 0000000..d49aa9c
--- /dev/null
+++ b/test/Preprocessor/ucn-allowed-chars.c
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c99 -verify
+// RUN: %clang_cc1 %s -fsyntax-only -std=c11 -Wc99-compat -verify
+// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++03 -Wc++11-compat -verify
+// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++11 -Wc++98-compat -verify
+
+// Identifier characters
+extern char a\u01F6; // C11, C++11
+extern char a\u00AA; // C99, C11, C++11
+extern char a\u0384; // C++03, C11, C++11
+extern char a\u0E50; // C99, C++03, C11, C++11
+extern char a\uFFFF; // none
+
+
+
+
+
+// Identifier initial characters
+extern char \u0E50; // C++03, C11, C++11
+extern char \u0300; // disallowed initially in C11/C++11, always in C99/C++03
+
+
+
+
+
+
+
+
+// Disallowed everywhere
+#define A \u0000 // expected-error{{control character}}
+#define B \u001F // expected-error{{control character}}
+#define C \u007F // expected-error{{control character}}
+#define D \u009F // expected-error{{control character}}
+#define E \uD800 // C++03 allows UCNs representing surrogate characters!
+
+
+
+
+
+
+#if __cplusplus
+# if __cplusplus >= 201103L
+// C++11
+// expected-warning@7 {{using this character in an identifier is incompatible with C++98}}
+// expected-warning@8 {{using this character in an identifier is incompatible with C++98}}
+// expected-error@11 {{expected ';'}}
+// expected-error@19 {{expected unqualified-id}}
+// expected-error@33 {{invalid universal character}}
+
+# else
+// C++03
+// expected-error@7 {{expected ';'}}
+// expected-error@8 {{expected ';'}}
+// expected-error@11 {{expected ';'}}
+// expected-error@19 {{expected unqualified-id}}
+// expected-warning@33 {{universal character name refers to a surrogate character}}
+
+# endif
+#else
+# if __STDC_VERSION__ >= 201112L
+// C11
+// expected-warning@7 {{using this character in an identifier is incompatible with C99}}
+// expected-warning@9 {{using this character in an identifier is incompatible with C99}}
+// expected-error@11 {{expected ';'}}
+// expected-warning@18 {{starting an identifier with this character is incompatible with C99}}
+// expected-error@19 {{expected identifier}}
+// expected-error@33 {{invalid universal character}}
+
+# else
+// C99
+// expected-error@7 {{expected ';'}}
+// expected-error@9 {{expected ';'}}
+// expected-error@11 {{expected ';'}}
+// expected-error@18 {{expected identifier}}
+// expected-error@19 {{expected identifier}}
+// expected-error@33 {{invalid universal character}}
+
+# endif
+#endif
diff --git a/test/Preprocessor/ucn-pp-identifier.c b/test/Preprocessor/ucn-pp-identifier.c
new file mode 100644
index 0000000..8616d40
--- /dev/null
+++ b/test/Preprocessor/ucn-pp-identifier.c
@@ -0,0 +1,106 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -verify -Wundef
+// RUN: %clang_cc1 %s -fsyntax-only -x c++ -pedantic -verify -Wundef
+// RUN: %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -Wundef 2>&1 | FileCheck -strict-whitespace %s
+
+#define \u00FC
+#define a\u00FD() 0
+#ifndef \u00FC
+#error "This should never happen"
+#endif
+
+#if a\u00FD()
+#error "This should never happen"
+#endif
+
+#if a\U000000FD()
+#error "This should never happen"
+#endif
+
+#if \uarecool // expected-warning{{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}}
+#endif
+#if \uwerecool // expected-warning{{\u used with no following hex digits; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}}
+#endif
+#if \U0001000 // expected-warning{{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{invalid token at start of a preprocessor expression}}
+#endif
+
+// Make sure we reject disallowed UCNs
+#define \ufffe // expected-error {{macro names must be identifiers}}
+#define \U10000000 // expected-error {{macro names must be identifiers}}
+#define \u0061 // expected-error {{character 'a' cannot be specified by a universal character name}} expected-error {{macro names must be identifiers}}
+
+// FIXME: Not clear what our behavior should be here; \u0024 is "$".
+#define a\u0024 // expected-warning {{whitespace}}
+
+#if \u0110 // expected-warning {{is not defined, evaluates to 0}}
+#endif
+
+
+#define \u0110 1 / 0
+#if \u0110 // expected-error {{division by zero in preprocessor expression}}
+#endif
+
+#define STRINGIZE(X) # X
+
+extern int check_size[sizeof(STRINGIZE(\u0112)) == 3 ? 1 : -1];
+
+// Check that we still diagnose disallowed UCNs in #if 0 blocks.
+// C99 5.1.1.2p1 and C++11 [lex.phases]p1 dictate that preprocessor tokens are
+// formed before directives are parsed.
+// expected-error@+4 {{character 'a' cannot be specified by a universal character name}}
+#if 0
+#define \ufffe // okay
+#define \U10000000 // okay
+#define \u0061 // error, but -verify only looks at comments outside #if 0
+#endif
+
+
+// A UCN formed by token pasting is undefined in both C99 and C++.
+// Right now we don't do anything special, which causes us to coincidentally
+// accept the first case below but reject the second two.
+#define PASTE(A, B) A ## B
+extern int PASTE(\, u00FD);
+extern int PASTE(\u, 00FD); // expected-warning{{\u used with no following hex digits}}
+extern int PASTE(\u0, 0FD); // expected-warning{{incomplete universal character name}}
+#ifdef __cplusplus
+// expected-error@-3 {{expected unqualified-id}}
+// expected-error@-3 {{expected unqualified-id}}
+#else
+// expected-error@-6 {{expected identifier}}
+// expected-error@-6 {{expected identifier}}
+#endif
+
+
+// A UCN produced by line splicing is valid in C99 but undefined in C++.
+// Since undefined behavior can do anything including working as intended,
+// we just accept it in C++ as well.;
+#define newline_1_\u00F\
+C 1
+#define newline_2_\u00\
+F\
+C 1
+#define newline_3_\u\
+00\
+FC 1
+#define newline_4_\\
+u00FC 1
+#define newline_5_\\
+u\
+\
+0\
+0\
+F\
+C 1
+
+#if (newline_1_\u00FC && newline_2_\u00FC && newline_3_\u00FC && \
+ newline_4_\u00FC && newline_5_\u00FC)
+#else
+#error "Line splicing failed to produce UCNs"
+#endif
+
+
+#define capital_u_\U00FC
+// expected-warning@-1 {{incomplete universal character name}} expected-note@-1 {{did you mean to use '\u'?}} expected-warning@-1 {{whitespace}}
+// CHECK: note: did you mean to use '\u'?
+// CHECK-NEXT: #define capital_u_\U00FC
+// CHECK-NEXT: {{^ \^}}
+// CHECK-NEXT: {{^ u}}
diff --git a/test/Preprocessor/utf8-allowed-chars.c b/test/Preprocessor/utf8-allowed-chars.c
new file mode 100644
index 0000000..b10ca74
--- /dev/null
+++ b/test/Preprocessor/utf8-allowed-chars.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c99 -verify
+// RUN: %clang_cc1 %s -fsyntax-only -std=c11 -Wc99-compat -verify
+// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++03 -Wc++11-compat -verify
+// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++11 -Wc++98-compat -verify
+
+// Note: This file contains Unicode characters; please do not remove them!
+
+// Identifier characters
+extern char aǶ; // C11, C++11
+extern char aª; // C99, C11, C++11
+extern char a΄; // C++03, C11, C++11
+extern char a๐; // C99, C++03, C11, C++11
+extern char a﹅; // none
+extern char x̀; // C11, C++11. Note that this does not have a composed form.
+
+
+
+
+// Identifier initial characters
+extern char ๐; // C++03, C11, C++11
+extern char ̀; // disallowed initially in C11/C++11, always in C99/C++03
+
+
+
+
+
+
+
+
+#if __cplusplus
+# if __cplusplus >= 201103L
+// C++11
+// expected-warning@9 {{using this character in an identifier is incompatible with C++98}}
+// expected-warning@10 {{using this character in an identifier is incompatible with C++98}}
+// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-warning@14 {{using this character in an identifier is incompatible with C++98}}
+// expected-error@21 {{expected unqualified-id}}
+
+# else
+// C++03
+// expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@10 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
+
+# endif
+#else
+# if __STDC_VERSION__ >= 201112L
+// C11
+// expected-warning@9 {{using this character in an identifier is incompatible with C99}}
+// expected-warning@11 {{using this character in an identifier is incompatible with C99}}
+// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-warning@14 {{using this character in an identifier is incompatible with C99}}
+// expected-warning@20 {{starting an identifier with this character is incompatible with C99}}
+// expected-error@21 {{expected identifier}}
+
+# else
+// C99
+// expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@11 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@20 {{expected identifier}}
+// expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
+
+# endif
+#endif
diff --git a/test/Preprocessor/warn-disabled-macro-expansion.c b/test/Preprocessor/warn-disabled-macro-expansion.c
index fe8e90c..21a3b7e 100644
--- a/test/Preprocessor/warn-disabled-macro-expansion.c
+++ b/test/Preprocessor/warn-disabled-macro-expansion.c
@@ -14,7 +14,10 @@
#define c(x) x(0)
-p // expected-warning {{recursive macro}}
+#define y(x) y
+#define z(x) (z)(x)
+
+p // no warning
a // expected-warning {{recursive macro}}
@@ -25,3 +28,8 @@ g(3) // expected-warning {{recursive macro}}
h(0) // expected-warning {{recursive macro}}
c(c) // expected-warning {{recursive macro}}
+
+y(5) // expected-warning {{recursive macro}}
+
+z(z) // ok
+
diff --git a/test/Preprocessor/warning_tests.c b/test/Preprocessor/warning_tests.c
index 3f2865c..c0c22ef 100644
--- a/test/Preprocessor/warning_tests.c
+++ b/test/Preprocessor/warning_tests.c
@@ -11,7 +11,9 @@
#warning Should have -Wparentheses
#endif
-#if __has_warning(-Wfoo) // expected-error {{builtin warning check macro requires a parenthesized string}}
+// expected-error@+2 {{expected string literal in '__has_warning'}}
+// expected-error@+1 {{expected value in expression}}
+#if __has_warning(-Wfoo)
#endif
// expected-warning@+3 {{Not a valid warning flag}}
@@ -19,3 +21,26 @@
#else
#warning Not a valid warning flag
#endif
+
+// expected-error@+2 {{builtin warning check macro requires a parenthesized string}}
+// expected-error@+1 {{invalid token}}
+#if __has_warning "not valid"
+#endif
+
+// Macro expansion does not occur in the parameter to __has_warning
+// (as is also expected behaviour for ordinary macros), so the
+// following should not expand:
+
+#define MY_ALIAS "-Wparentheses"
+
+// expected-error@+1 2{{expected}}
+#if __has_warning(MY_ALIAS)
+#error Alias expansion not allowed
+#endif
+
+// But deferring should expand:
+#define HAS_WARNING(X) __has_warning(X)
+
+#if !HAS_WARNING(MY_ALIAS)
+#error Expansion should have occurred
+#endif
OpenPOWER on IntegriCloud