1 /* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
2 Copyright (C) 1992 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24 #ifdef HANDLE_SYSV_PRAGMA
26 /* When structure field packing is in effect, this variable is the
27 number of bits to use as the maximum alignment. When packing is not
28 in effect, this is zero. */
30 extern int maximum_field_alignment;
32 /* Handle one token of a pragma directive. TOKEN is the
33 current token, and STRING is its printable form. */
36 handle_pragma_token (string, token)
40 static enum pragma_state
53 } state = ps_start, type;
62 if (state == ps_right)
63 maximum_field_alignment = align * 8;
65 warning ("malformed `#pragma pack'");
68 else if (type == ps_weak)
70 if (state == ps_name || state == ps_value)
72 fprintf (asm_out_file, "\t%s\t", WEAK_ASM_OP);
73 ASM_OUTPUT_LABELREF (asm_out_file, name);
74 fputc ('\n', asm_out_file);
75 if (state == ps_value)
77 fprintf (asm_out_file, "\t%s\t", SET_ASM_OP);
78 ASM_OUTPUT_LABELREF (asm_out_file, name);
79 fputc (',', asm_out_file);
80 ASM_OUTPUT_LABELREF (asm_out_file, value);
81 fputc ('\n', asm_out_file);
84 else if (! (state == ps_done || state == ps_start))
85 warning ("malformed `#pragma weak'");
87 #endif /* WEAK_ASM_OP */
89 type = state = ps_start;
96 if (token && TREE_CODE (token) == IDENTIFIER_NODE)
98 if (strcmp (IDENTIFIER_POINTER (token), "pack") == 0)
99 type = state = ps_pack;
101 else if (strcmp (IDENTIFIER_POINTER (token), "weak") == 0)
102 type = state = ps_weak;
105 type = state = ps_done;
108 type = state = ps_done;
113 if (token && TREE_CODE (token) == IDENTIFIER_NODE)
115 name = IDENTIFIER_POINTER (token);
123 state = (strcmp (string, "=") ? ps_bad : ps_equals);
127 if (token && TREE_CODE (token) == IDENTIFIER_NODE)
129 value = IDENTIFIER_POINTER (token);
139 #endif /* WEAK_ASM_OP */
142 if (strcmp (string, "(") == 0)
149 if (token && TREE_CODE (token) == INTEGER_CST
150 && TREE_INT_CST_HIGH (token) == 0)
151 switch (TREE_INT_CST_LOW (token))
156 align = TREE_INT_CST_LOW (token);
163 else if (! token && strcmp (string, ")") == 0)
173 if (strcmp (string, ")") == 0)
191 #endif /* HANDLE_SYSV_PRAGMA */