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. */
25 #ifdef HANDLE_SYSV_PRAGMA
27 /* Support #pragma weak by default if WEAK_ASM_OP is defined. */
28 #if !defined (HANDLE_PRAGMA_WEAK) && defined (WEAK_ASM_OP) && defined (SET_ASM_OP)
29 #define HANDLE_PRAGMA_WEAK 1
32 /* See varasm.c for an identical definition. */
48 /* When structure field packing is in effect, this variable is the
49 number of bits to use as the maximum alignment. When packing is not
50 in effect, this is zero. */
52 extern int maximum_field_alignment;
54 /* File used for outputting assembler code. */
55 extern FILE *asm_out_file;
57 /* Handle one token of a pragma directive. TOKEN is the
58 current token, and STRING is its printable form. */
61 handle_pragma_token (string, token)
65 static enum pragma_state state = ps_start, type;
74 if (state == ps_right)
75 maximum_field_alignment = align * 8;
77 warning ("malformed `#pragma pack'");
79 else if (type == ps_weak)
81 #ifdef HANDLE_PRAGMA_WEAK
82 if (HANDLE_PRAGMA_WEAK)
83 handle_pragma_weak (state, asm_out_file, name, value);
85 #endif /* HANDLE_PRAMA_WEAK */
88 type = state = ps_start;
95 if (token && TREE_CODE (token) == IDENTIFIER_NODE)
97 if (strcmp (IDENTIFIER_POINTER (token), "pack") == 0)
98 type = state = ps_pack;
99 else if (strcmp (IDENTIFIER_POINTER (token), "weak") == 0)
100 type = state = ps_weak;
102 type = state = ps_done;
105 type = state = ps_done;
109 if (token && TREE_CODE (token) == IDENTIFIER_NODE)
111 name = IDENTIFIER_POINTER (token);
119 state = (strcmp (string, "=") ? ps_bad : ps_equals);
123 if (token && TREE_CODE (token) == IDENTIFIER_NODE)
125 value = IDENTIFIER_POINTER (token);
137 if (strcmp (string, "(") == 0)
144 if (token && TREE_CODE (token) == INTEGER_CST
145 && TREE_INT_CST_HIGH (token) == 0)
146 switch (TREE_INT_CST_LOW (token))
151 align = TREE_INT_CST_LOW (token);
158 else if (! token && strcmp (string, ")") == 0)
168 if (strcmp (string, ")") == 0)
186 #endif /* HANDLE_SYSV_PRAGMA */