1 /* Darwin support needed only by C/C++ frontends.
3 Free Software Foundation, Inc.
4 Contributed by Apple Computer Inc.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
35 #define BAD(msgid) do { warning (msgid); return; } while (0)
37 /* Maintain a small stack of alignments. This is similar to pragma
38 pack's stack, but simpler. */
40 static void push_field_alignment
PARAMS ((int));
41 static void pop_field_alignment
PARAMS ((void));
43 typedef struct align_stack
46 struct align_stack
* prev
;
49 static struct align_stack
* field_align_stack
= NULL
;
52 push_field_alignment (bit_alignment
)
55 align_stack
*entry
= (align_stack
*) xmalloc (sizeof (align_stack
));
57 entry
->alignment
= maximum_field_alignment
;
58 entry
->prev
= field_align_stack
;
59 field_align_stack
= entry
;
61 maximum_field_alignment
= bit_alignment
;
65 pop_field_alignment ()
67 if (field_align_stack
)
69 align_stack
*entry
= field_align_stack
;
71 maximum_field_alignment
= entry
->alignment
;
72 field_align_stack
= entry
->prev
;
76 error ("too many #pragma options align=reset");
79 /* Handlers for Darwin-specific pragmas. */
82 darwin_pragma_ignore (pfile
)
83 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
88 /* #pragma options align={mac68k|power|reset} */
91 darwin_pragma_options (pfile
)
92 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
97 if (c_lex (&t
) != CPP_NAME
)
98 BAD ("malformed '#pragma options', ignoring");
99 arg
= IDENTIFIER_POINTER (t
);
100 if (strcmp (arg
, "align"))
101 BAD ("malformed '#pragma options', ignoring");
102 if (c_lex (&t
) != CPP_EQ
)
103 BAD ("malformed '#pragma options', ignoring");
104 if (c_lex (&t
) != CPP_NAME
)
105 BAD ("malformed '#pragma options', ignoring");
107 if (c_lex (&x
) != CPP_EOF
)
108 warning ("junk at end of '#pragma options'");
110 arg
= IDENTIFIER_POINTER (t
);
111 if (!strcmp (arg
, "mac68k"))
112 push_field_alignment (16);
113 else if (!strcmp (arg
, "power"))
114 push_field_alignment (0);
115 else if (!strcmp (arg
, "reset"))
116 pop_field_alignment ();
118 warning ("malformed '#pragma options align={mac68k|power|reset}', ignoring");
121 /* #pragma unused ([var {, var}*]) */
124 darwin_pragma_unused (pfile
)
125 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
130 if (c_lex (&x
) != CPP_OPEN_PAREN
)
131 BAD ("missing '(' after '#pragma unused', ignoring");
136 if (tok
== CPP_NAME
&& decl
)
138 tree local
= IDENTIFIER_LOCAL_VALUE (decl
);
139 if (local
&& (TREE_CODE (local
) == PARM_DECL
140 || TREE_CODE (local
) == VAR_DECL
))
141 TREE_USED (local
) = 1;
143 if (tok
!= CPP_COMMA
)
148 if (tok
!= CPP_CLOSE_PAREN
)
149 BAD ("missing ')' after '#pragma unused', ignoring");
151 if (c_lex (&x
) != CPP_EOF
)
152 warning ("junk at end of '#pragma unused'");