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