xref: /aosp_15_r20/external/clang/test/PCH/pragma-ms_struct.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test this without pch.
2*67e74705SXin Li // RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple i386-apple-darwin9 -fsyntax-only -include %s -verify -std=c++11
3*67e74705SXin Li 
4*67e74705SXin Li // Test with pch.
5*67e74705SXin Li // RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple i386-apple-darwin9 -emit-pch -o %t -std=c++11
6*67e74705SXin Li // RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple i386-apple-darwin9 -fsyntax-only -include-pch %t -verify -std=c++11
7*67e74705SXin Li 
8*67e74705SXin Li // The first run line creates a pch, and since at that point HEADER is not
9*67e74705SXin Li // defined, the only thing contained in the pch is the pragma. The second line
10*67e74705SXin Li // then includes that pch, so HEADER is defined and the actual code is compiled.
11*67e74705SXin Li // The check then makes sure that the pragma is in effect in the file that
12*67e74705SXin Li // includes the pch.
13*67e74705SXin Li 
14*67e74705SXin Li // expected-no-diagnostics
15*67e74705SXin Li 
16*67e74705SXin Li #ifndef HEADER
17*67e74705SXin Li #define HEADER
18*67e74705SXin Li struct SOffH {
19*67e74705SXin Li   short m : 9;
20*67e74705SXin Li   int q : 12;
21*67e74705SXin Li };
22*67e74705SXin Li 
23*67e74705SXin Li #pragma ms_struct on
24*67e74705SXin Li 
25*67e74705SXin Li struct SOnH {
26*67e74705SXin Li   short m : 9;
27*67e74705SXin Li   int q : 12;
28*67e74705SXin Li };
29*67e74705SXin Li 
30*67e74705SXin Li #else
31*67e74705SXin Li 
32*67e74705SXin Li struct SOnC {
33*67e74705SXin Li   short m : 9;
34*67e74705SXin Li   int q : 12;
35*67e74705SXin Li };
36*67e74705SXin Li 
37*67e74705SXin Li static_assert(sizeof(SOffH) == 4, "");
38*67e74705SXin Li static_assert(sizeof(SOnH) == 8, "");
39*67e74705SXin Li static_assert(sizeof(SOnC) == 8, "");
40*67e74705SXin Li 
41*67e74705SXin Li #endif
42