xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/pragma-ms_struct.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc #pragma ms_struct on
4f4a2713aSLionel Sambuc 
5f4a2713aSLionel Sambuc #pragma ms_struct off
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc #pragma ms_struct reset
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc #pragma ms_struct // expected-warning {{incorrect use of '#pragma ms_struct on|off' - ignored}}
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc #pragma ms_struct on top of spaghetti  // expected-warning {{extra tokens at end of '#pragma ms_struct' - ignored}}
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc struct foo
14f4a2713aSLionel Sambuc {
15f4a2713aSLionel Sambuc   int a;
16f4a2713aSLionel Sambuc   int b;
17f4a2713aSLionel Sambuc   char c;
18f4a2713aSLionel Sambuc };
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc struct {
22f4a2713aSLionel Sambuc                    unsigned long bf_1 : 12;
23f4a2713aSLionel Sambuc                    unsigned long : 0;
24f4a2713aSLionel Sambuc                    unsigned long bf_2 : 12;
25f4a2713aSLionel Sambuc } __attribute__((__ms_struct__)) t1;
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc struct S {
28*0a6a1f1dSLionel Sambuc 		   double __attribute__((ms_struct)) d;	// expected-warning {{'ms_struct' attribute only applies to struct or union}}
29f4a2713aSLionel Sambuc                    unsigned long bf_1 : 12;
30f4a2713aSLionel Sambuc                    unsigned long : 0;
31f4a2713aSLionel Sambuc                    unsigned long bf_2 : 12;
32f4a2713aSLionel Sambuc } __attribute__((ms_struct)) t2;
33f4a2713aSLionel Sambuc 
34f4a2713aSLionel Sambuc enum
35f4a2713aSLionel Sambuc {
36f4a2713aSLionel Sambuc   A = 0,
37f4a2713aSLionel Sambuc   B,
38f4a2713aSLionel Sambuc   C
39*0a6a1f1dSLionel Sambuc } __attribute__((ms_struct)) e1; // expected-warning {{'ms_struct' attribute only applies to struct or union}}
40f4a2713aSLionel Sambuc 
41f4a2713aSLionel Sambuc // rdar://10513599
42f4a2713aSLionel Sambuc #pragma ms_struct on
43f4a2713aSLionel Sambuc 
44f4a2713aSLionel Sambuc typedef struct
45f4a2713aSLionel Sambuc {
46f4a2713aSLionel Sambuc void *pv;
47f4a2713aSLionel Sambuc int l;
48f4a2713aSLionel Sambuc } Foo;
49f4a2713aSLionel Sambuc 
50f4a2713aSLionel Sambuc typedef struct
51f4a2713aSLionel Sambuc {
52f4a2713aSLionel Sambuc void *pv1;
53f4a2713aSLionel Sambuc Foo foo;
54f4a2713aSLionel Sambuc unsigned short fInited : 1;
55f4a2713aSLionel Sambuc void *pv2;
56f4a2713aSLionel Sambuc } PackOddity;
57f4a2713aSLionel Sambuc 
58f4a2713aSLionel Sambuc #pragma ms_struct off
59f4a2713aSLionel Sambuc 
60f4a2713aSLionel Sambuc static int arr[sizeof(PackOddity) == 40 ? 1 : -1];
61f4a2713aSLionel Sambuc 
62*0a6a1f1dSLionel Sambuc struct __declspec(ms_struct) bad { // expected-warning {{__declspec attribute 'ms_struct' is not supported}}
63*0a6a1f1dSLionel Sambuc };
64