* Makefile.in (rtlanal.o): Depend on $(TM_P_H).
[official-gcc.git] / gcc / config / darwin-c.c
blob10ffaf0993507a27bc4c6c9810cc2e47ad666e5b
1 /* Darwin support needed only by C/C++ frontends.
2 Copyright (C) 2001
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)
11 any later version.
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. */
23 #include "config.h"
24 #include "system.h"
25 #include "cpplib.h"
26 #include "tree.h"
27 #include "c-pragma.h"
28 #include "c-lex.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 PARAMS ((int));
41 static void pop_field_alignment PARAMS ((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 (bit_alignment)
53 int 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;
64 static void
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;
73 free (entry);
75 else
76 error ("too many #pragma options align=reset");
79 /* Handlers for Darwin-specific pragmas. */
81 void
82 darwin_pragma_ignore (pfile)
83 cpp_reader *pfile ATTRIBUTE_UNUSED;
85 /* Do nothing. */
88 /* #pragma options align={mac68k|power|reset} */
90 void
91 darwin_pragma_options (pfile)
92 cpp_reader *pfile ATTRIBUTE_UNUSED;
94 char *arg;
95 tree t, x;
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 ();
117 else
118 warning ("malformed '#pragma options align={mac68k|power|reset}', ignoring");
121 /* #pragma unused ([var {, var}*]) */
123 void
124 darwin_pragma_unused (pfile)
125 cpp_reader *pfile ATTRIBUTE_UNUSED;
127 tree decl, x;
128 int tok;
130 if (c_lex (&x) != CPP_OPEN_PAREN)
131 BAD ("missing '(' after '#pragma unused', ignoring");
133 while (1)
135 tok = c_lex (&decl);
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;
142 tok = c_lex (&x);
143 if (tok != CPP_COMMA)
144 break;
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'");