1 /* Darwin (Mac OS X) pragma exercises.  */
2 
3 /* { dg-do run { target *-*-darwin* } } */
4 /* { dg-options "-O -Wunused" } */
5 
6 /* The mark pragma is to help decorate IDEs.  */
7 
8 extern void abort(void);
9 
10 #pragma mark hey hey ho
11 
12 /* The options pragma used to do a lot, now it's only for emulating
13    m68k alignment rules in structs.  */
14 
15 #pragma options 23  /* { dg-warning "malformed '#pragma options'" } */
16 #pragma options align  /* { dg-warning "malformed '#pragma options'" } */
17 #pragma options align natural /* { dg-warning "malformed '#pragma options'" } */
18 #pragma options align=45 /* { dg-warning "malformed '#pragma options'" } */
19 #pragma options align=foo /* { dg-warning "malformed '#pragma options align" } */
20 
21 #ifndef __LP64__
22 #pragma options align=mac68k
23 struct s1 { short f1; int f2; };
24 #endif
25 #pragma options align=power
26 struct s2 { short f1; int f2; };
27 #ifndef __LP64__
28 #pragma options align=mac68k
29 struct s3 { short f1; int f2; };
30 #endif
31 #pragma options align=reset
32 struct s4 { short f1; int f2; };
33 
34 #pragma options align=natural foo /* { dg-warning "junk at end of '#pragma options'" } */
35 /* { dg-warning "malformed '#pragma options align={mac68k|power|reset}', ignoring" "ignoring" { target *-*-* } 34 } */
36 
37 /* Segment pragmas don't do anything anymore.  */
38 
39 #pragma segment foo
40 
41 int
main()42 main ()
43 {
44   int x, z;  /* { dg-warning "unused variable 'z'" } */
45   #pragma unused (x, y)
46 
47 #ifndef __LP64__
48   if (sizeof (struct s1) != 6)
49     abort ();
50 #endif
51   if (sizeof (struct s2) != 8)
52     abort ();
53 #ifndef __LP64__
54   if (sizeof (struct s3) != 6)
55     abort ();
56 #endif
57   if (sizeof (struct s4) != 8)
58     abort ();
59   return 0;
60 }
61 
62 void
unused_err_test()63 unused_err_test ()
64 {
65   int a, b;
66   /* Trying to match on '(' or ')' gives regexp headaches, use . instead.  */
67 #pragma unused  /* { dg-warning "missing '.' after '#pragma unused" } */
68 #pragma unused (a  /* { dg-warning "missing '.' after '#pragma unused" } */
69 #pragma unused (b) foo /* { dg-warning "junk at end of '#pragma unused'" } */
70 }
71