* config/sparc/sol2-bi.h: Handle TARGET_CPU_ultrasparc3.
[official-gcc.git] / gcc / config / darwin-c.c
blobfb51455ae6243060027518de6a0bd951c2c2eadb
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)
10 any later version.
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. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "cpplib.h"
27 #include "tree.h"
28 #include "c-pragma.h"
29 #include "c-tree.h"
30 #include "toplev.h"
31 #include "tm_p.h"
33 /* Pragmas. */
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
45 int alignment;
46 struct align_stack * prev;
47 } align_stack;
49 static struct align_stack * field_align_stack = NULL;
51 static void
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;
63 static void
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;
72 free (entry);
74 else
75 error ("too many #pragma options align=reset");
78 /* Handlers for Darwin-specific pragmas. */
80 void
81 darwin_pragma_ignore (cpp_reader *pfile ATTRIBUTE_UNUSED)
83 /* Do nothing. */
86 /* #pragma options align={mac68k|power|reset} */
88 void
89 darwin_pragma_options (cpp_reader *pfile ATTRIBUTE_UNUSED)
91 const char *arg;
92 tree t, x;
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 ();
114 else
115 warning ("malformed '#pragma options align={mac68k|power|reset}', ignoring");
118 /* #pragma unused ([var {, var}*]) */
120 void
121 darwin_pragma_unused (cpp_reader *pfile ATTRIBUTE_UNUSED)
123 tree decl, x;
124 int tok;
126 if (c_lex (&x) != CPP_OPEN_PAREN)
127 BAD ("missing '(' after '#pragma unused', ignoring");
129 while (1)
131 tok = c_lex (&decl);
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;
138 tok = c_lex (&x);
139 if (tok != CPP_COMMA)
140 break;
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'");