]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/darwin-c.c
1 /* Darwin support needed only by C/C++ frontends.
2 Copyright (C) 2001, 2003 Free Software Foundation, Inc.
3 Contributed by Apple Computer Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "coretypes.h"
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 (int);
41 static void pop_field_alignment (void);
43 typedef struct align_stack
46 struct align_stack
* prev
;
49 static struct align_stack
* field_align_stack
= NULL
;
52 push_field_alignment (int bit_alignment
)
54 align_stack
*entry
= (align_stack
*) xmalloc (sizeof (align_stack
));
56 entry
->alignment
= maximum_field_alignment
;
57 entry
->prev
= field_align_stack
;
58 field_align_stack
= entry
;
60 maximum_field_alignment
= bit_alignment
;
64 pop_field_alignment (void)
66 if (field_align_stack
)
68 align_stack
*entry
= field_align_stack
;
70 maximum_field_alignment
= entry
->alignment
;
71 field_align_stack
= entry
->prev
;
75 error ("too many #pragma options align=reset");
78 /* Handlers for Darwin-specific pragmas. */
81 darwin_pragma_ignore (cpp_reader
*pfile ATTRIBUTE_UNUSED
)
86 /* #pragma options align={mac68k|power|reset} */
89 darwin_pragma_options (cpp_reader
*pfile ATTRIBUTE_UNUSED
)
94 if (c_lex (&t
) != CPP_NAME
)
95 BAD ("malformed '#pragma options', ignoring");
96 arg
= IDENTIFIER_POINTER (t
);
97 if (strcmp (arg
, "align"))
98 BAD ("malformed '#pragma options', ignoring");
99 if (c_lex (&t
) != CPP_EQ
)
100 BAD ("malformed '#pragma options', ignoring");
101 if (c_lex (&t
) != CPP_NAME
)
102 BAD ("malformed '#pragma options', ignoring");
104 if (c_lex (&x
) != CPP_EOF
)
105 warning ("junk at end of '#pragma options'");
107 arg
= IDENTIFIER_POINTER (t
);
108 if (!strcmp (arg
, "mac68k"))
109 push_field_alignment (16);
110 else if (!strcmp (arg
, "power"))
111 push_field_alignment (0);
112 else if (!strcmp (arg
, "reset"))
113 pop_field_alignment ();
115 warning ("malformed '#pragma options align={mac68k|power|reset}', ignoring");
118 /* #pragma unused ([var {, var}*]) */
121 darwin_pragma_unused (cpp_reader
*pfile ATTRIBUTE_UNUSED
)
126 if (c_lex (&x
) != CPP_OPEN_PAREN
)
127 BAD ("missing '(' after '#pragma unused', ignoring");
132 if (tok
== CPP_NAME
&& decl
)
134 tree local
= lookup_name (decl
);
135 if (local
&& (TREE_CODE (local
) == PARM_DECL
136 || TREE_CODE (local
) == VAR_DECL
))
137 TREE_USED (local
) = 1;
139 if (tok
!= CPP_COMMA
)
144 if (tok
!= CPP_CLOSE_PAREN
)
145 BAD ("missing ')' after '#pragma unused', ignoring");
147 if (c_lex (&x
) != CPP_EOF
)
148 warning ("junk at end of '#pragma unused'");