1 // RUN: %clang_cc1 -fms-extensions -std=c++11 -E %s -fuse-line-directives | FileCheck %s
2 
3 // Test that we properly expand the C99 _Pragma and Microsoft __pragma
4 // into #pragma directives, with newlines where needed. <rdar://problem/8412013>
5 
6 // CHECK: #line
7 // CHECK: #pragma warning(push)
8 // CHECK: extern "C" {
9 // CHECK: #line
10 // CHECK: #pragma warning(push)
11 // CHECK:  int foo() { return 0; } }
12 // CHECK: #pragma warning(pop)
13 #define A(X) extern "C" { __pragma(warning(push)) \
14   int X() { return 0; } \
15 }
16 #define B(X) A(X)
17 #pragma warning(push)
18 B(foo)
19 #pragma warning(pop)
20 
21 #define pragma_L _Pragma(L"GCC diagnostic push")
22 #define pragma_u8 _Pragma(u8"system_header")
23 #define pragma_u _Pragma(u"GCC diagnostic pop")
24 #define pragma_U _Pragma(U"comment(lib, \"libfoo\")")
25 #define pragma_R _Pragma(R"(clang diagnostic ignored "-Wunused")")
26 #define pragma_UR _Pragma(UR"(clang diagnostic error "-Wunused")")
27 #define pragma_hello _Pragma(u8R"x(message R"y("Hello", world!)y")x")
28 // CHECK: int n =
29 // CHECK: #pragma GCC diagnostic push
30 // CHECK: #pragma system_header
31 // CHECK: #pragma GCC diagnostic pop
32 // CHECK: #pragma comment(lib, "libfoo")
33 // CHECK: #pragma clang diagnostic ignored "-Wunused"
34 // CHECK: #pragma clang diagnostic error "-Wunused"
35 // CHECK: #pragma message("\042Hello\042, world!")
36 // CHECK: 0;
37 int n = pragma_L pragma_u8 pragma_u pragma_U pragma_R pragma_UR pragma_hello 0;
38 
39 #pragma warning(disable : 1 2L 3U ; error : 4 5 6 ; suppress : 7 8 9)
40 // CHECK: #pragma warning(disable: 1 2 3)
41 // CHECK: #line [[@LINE-2]]
42 // CHECK: #pragma warning(error: 4 5 6)
43 // CHECK: #line [[@LINE-4]]
44 // CHECK: #pragma warning(suppress: 7 8 9)
45 
46 #pragma warning(push)
47 #pragma warning(push, 1L)
48 #pragma warning(push, 4U)
49 #pragma warning(push, 0x1)
50 #pragma warning(push, 03)
51 #pragma warning(push, 0b10)
52 #pragma warning(push, 1i8)
53 // CHECK: #pragma warning(push)
54 // CHECK: #pragma warning(push, 1)
55 // CHECK: #pragma warning(push, 4)
56 // CHECK: #pragma warning(push, 1)
57 // CHECK: #pragma warning(push, 3)
58 // CHECK: #pragma warning(push, 2)
59 // CHECK: #pragma warning(push, 1)
60