1992-06-29 23:11:04 -04:00
|
|
|
|
/* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
|
1999-04-26 17:18:08 -04:00
|
|
|
|
Copyright (C) 1992, 1997, 1998, 1999 Free Software Foundation, Inc.
|
1992-06-29 23:11:04 -04:00
|
|
|
|
|
|
|
|
|
This file is part of GNU CC.
|
|
|
|
|
|
|
|
|
|
GNU CC is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
GNU CC is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with GNU CC; see the file COPYING. If not, write to
|
1995-06-15 07:33:25 -04:00
|
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1992-06-29 23:11:04 -04:00
|
|
|
|
|
1992-06-29 23:17:52 -04:00
|
|
|
|
#include "config.h"
|
Major cutover to using system.h:
* Makefile.in (alias.o, bitmap.o, c-aux-info.o, c-common.o,
c-decl.o, c-iterate.o, c-lang.o, c-lex.o, c-pragma.o, c-typeck.o,
caller-save.o, calls.o, collect2.o, combine.o, cse.o, dbxout.o,
dwarf2out.o, dwarfout.o, emit-rtl.o, except.o, explow.o, expmed.o,
expr.o, final.o, flow.o, function.o, getpwd.o, global.o,
integrate.o, jump.o, local-alloc.o, loop.o, optabs.o, pexecute.o,
prefix.o, print-rtl.o, print-tree.o, profile.o, real.o, recog.o,
reg-stack.o, regclass.o, regmove.o, reload.o, reload1.o, reorg.o,
rtl.o, rtlanal.o, sdbout.o, stmt.o, stor-layout.o, stupid.o,
tlink.o, toplev.o, tree.o, unroll.o, varasm.o, xcoffout.o): Depend
on system.h.
* alias.c, bitmap.c, c-aux-info.c, c-common.c, c-decl.c,
c-iterate.c, c-lang.c, c-lex.c, c-pragma.c, c-typeck.c,
caller-save.c, calls.c, collect2.c, combine.c, cse.c, dbxout.c,
dwarf2out.c, dwarfout.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, flow.c, function.c, gcc.c, getpwd.c, global.c,
integrate.c, jump.c, local-alloc.c, loop.c, optabs.c, pexecute.c,
prefix.c, print-rtl.c, print-tree.c, profile.c, real.c, recog.c,
reg-stack.c, regclass.c, regmove.c, reload.c, reload1.c, reorg.c,
rtl.c, rtlanal.c, sched.c, sdbout.c, stmt.c, stor-layout.c,
stupid.c, tlink.c, toplev.c, tree.c, unroll.c, varasm.c,
xcoffout.c: Include system.h. Organize include ordering so
that stdarg/varargs comes before other system headers. Remove
spurious casts of functions assured of a prototype in system.h.
From-SVN: r18726
1998-03-20 09:58:42 -05:00
|
|
|
|
#include "system.h"
|
1998-05-28 02:47:21 -04:00
|
|
|
|
#include "rtl.h"
|
1992-06-29 23:17:52 -04:00
|
|
|
|
#include "tree.h"
|
1996-07-23 16:09:26 -04:00
|
|
|
|
#include "except.h"
|
1993-09-21 17:25:24 -04:00
|
|
|
|
#include "function.h"
|
1994-02-27 19:47:28 -05:00
|
|
|
|
#include "defaults.h"
|
1995-04-18 14:16:51 -04:00
|
|
|
|
#include "c-pragma.h"
|
1997-12-22 05:05:04 -05:00
|
|
|
|
#include "flags.h"
|
toplev.h: New file.
Wed May 6 06:35:38 1998 Robert Lipe <robertl@dgii.com>
* toplev.h: New file. Protypes for functions in toplev.c.
* tree.h, rtl.h: Deleted protos for functions in toplev.c.
* c-common.c, c-convert.c, c-decl.c, c-iterate.c, c-lex.c,
c-parse.in, c-parse.y, c-pragma.c, c-typeck.c, calls.c,
convert.c, dwarf2out.c, except.c, expr.c, final.c, fold-const.c,
function.c, hash.c, profile.c, real.c, reg-stack.c, regclass.c,
reload.c, reload1.c, stmt.c, stor-layout.c, tlink.c, tree.c,
varasm.c: include it.
From-SVN: r19563
1998-05-06 00:45:47 -04:00
|
|
|
|
#include "toplev.h"
|
1992-06-29 23:17:52 -04:00
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#ifdef HANDLE_GENERIC_PRAGMAS
|
1992-06-29 23:11:04 -04:00
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#ifdef HANDLE_PRAGMA_PACK
|
1992-06-29 23:11:04 -04:00
|
|
|
|
/* When structure field packing is in effect, this variable is the
|
|
|
|
|
number of bits to use as the maximum alignment. When packing is not
|
1996-07-03 18:07:53 -04:00
|
|
|
|
in effect, this is zero. */
|
1992-06-29 23:11:04 -04:00
|
|
|
|
|
|
|
|
|
extern int maximum_field_alignment;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HANDLE_PRAGMA_PACK_PUSH_POP
|
|
|
|
|
typedef struct align_stack
|
|
|
|
|
{
|
|
|
|
|
int alignment;
|
|
|
|
|
unsigned int num_pushes;
|
1999-04-26 17:18:08 -04:00
|
|
|
|
tree id;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
struct align_stack * prev;
|
|
|
|
|
} align_stack;
|
|
|
|
|
|
|
|
|
|
static struct align_stack * alignment_stack = NULL;
|
|
|
|
|
|
1999-04-26 17:18:08 -04:00
|
|
|
|
static int push_alignment PROTO((int, tree));
|
|
|
|
|
static int pop_alignment PROTO((tree));
|
1998-10-01 06:50:15 -04:00
|
|
|
|
|
|
|
|
|
/* Push an alignment value onto the stack. */
|
|
|
|
|
static int
|
1999-04-26 17:18:08 -04:00
|
|
|
|
push_alignment (alignment, id)
|
1998-10-01 06:50:15 -04:00
|
|
|
|
int alignment;
|
1999-04-26 17:18:08 -04:00
|
|
|
|
tree id;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
{
|
|
|
|
|
switch (alignment)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
case 1:
|
|
|
|
|
case 2:
|
|
|
|
|
case 4:
|
|
|
|
|
case 8:
|
|
|
|
|
case 16:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
warning ("\
|
|
|
|
|
Alignment must be a small power of two, not %d, in #pragma pack",
|
|
|
|
|
alignment);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (alignment_stack == NULL
|
1999-04-26 17:18:08 -04:00
|
|
|
|
|| alignment_stack->alignment != alignment
|
|
|
|
|
|| id != NULL_TREE)
|
1998-10-01 06:50:15 -04:00
|
|
|
|
{
|
|
|
|
|
align_stack * entry;
|
|
|
|
|
|
|
|
|
|
entry = (align_stack *) xmalloc (sizeof (* entry));
|
|
|
|
|
|
|
|
|
|
if (entry == NULL)
|
|
|
|
|
{
|
|
|
|
|
warning ("Out of memory pushing #pragma pack");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entry->alignment = alignment;
|
|
|
|
|
entry->num_pushes = 1;
|
1999-04-26 17:18:08 -04:00
|
|
|
|
entry->id = id;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
entry->prev = alignment_stack;
|
|
|
|
|
|
|
|
|
|
alignment_stack = entry;
|
|
|
|
|
|
1999-04-26 17:18:08 -04:00
|
|
|
|
maximum_field_alignment = alignment * 8;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
alignment_stack->num_pushes ++;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Undo a push of an alignment onto the stack. */
|
|
|
|
|
static int
|
1999-04-26 17:18:08 -04:00
|
|
|
|
pop_alignment (id)
|
|
|
|
|
tree id;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
{
|
1999-04-26 17:18:08 -04:00
|
|
|
|
align_stack * entry;
|
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
if (alignment_stack == NULL)
|
|
|
|
|
{
|
|
|
|
|
warning ("\
|
1999-04-26 17:18:08 -04:00
|
|
|
|
#pragma pack (pop) encountered without matching #pragma pack (push, <n>)"
|
|
|
|
|
);
|
1998-10-01 06:50:15 -04:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-26 17:18:08 -04:00
|
|
|
|
/* If we got an identifier, strip away everything above the target
|
|
|
|
|
entry so that the next step will restore the state just below it. */
|
|
|
|
|
if (id)
|
|
|
|
|
{
|
|
|
|
|
for (entry = alignment_stack; entry; entry = entry->prev)
|
|
|
|
|
if (entry->id == id)
|
|
|
|
|
{
|
|
|
|
|
entry->num_pushes = 1;
|
|
|
|
|
alignment_stack = entry;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (entry == NULL)
|
|
|
|
|
warning ("\
|
|
|
|
|
#pragma pack(pop, %s) encountered without matching #pragma pack(push, %s, <n>)"
|
|
|
|
|
, IDENTIFIER_POINTER (id), IDENTIFIER_POINTER (id));
|
|
|
|
|
}
|
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
if (-- alignment_stack->num_pushes == 0)
|
|
|
|
|
{
|
|
|
|
|
entry = alignment_stack->prev;
|
|
|
|
|
|
|
|
|
|
if (entry == NULL || entry->alignment > 4)
|
|
|
|
|
maximum_field_alignment = 0;
|
|
|
|
|
else
|
|
|
|
|
maximum_field_alignment = entry->alignment * 8;
|
|
|
|
|
|
|
|
|
|
free (alignment_stack);
|
|
|
|
|
|
|
|
|
|
alignment_stack = entry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Generate 'packed' and 'aligned' attributes for decls whilst a
|
|
|
|
|
#pragma pack(push... is in effect. */
|
|
|
|
|
void
|
|
|
|
|
insert_pack_attributes (node, attributes, prefix)
|
|
|
|
|
tree node;
|
|
|
|
|
tree * attributes;
|
|
|
|
|
tree * prefix;
|
|
|
|
|
{
|
|
|
|
|
tree a;
|
|
|
|
|
|
|
|
|
|
/* If we are not packing, then there is nothing to do. */
|
1998-10-07 10:41:42 -04:00
|
|
|
|
if (maximum_field_alignment == 0
|
|
|
|
|
|| alignment_stack == NULL)
|
1998-10-01 06:50:15 -04:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* We are only interested in fields. */
|
|
|
|
|
if (TREE_CODE_CLASS (TREE_CODE (node)) != 'd'
|
|
|
|
|
|| TREE_CODE (node) != FIELD_DECL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Add a 'packed' attribute. */
|
|
|
|
|
* attributes = tree_cons (get_identifier ("packed"), NULL, * attributes);
|
|
|
|
|
|
|
|
|
|
/* If the alignment is > 8 then add an alignment attribute as well. */
|
|
|
|
|
if (maximum_field_alignment > 8)
|
|
|
|
|
{
|
|
|
|
|
/* If the aligned attribute is already present then do not override it. */
|
|
|
|
|
for (a = * attributes; a; a = TREE_CHAIN (a))
|
|
|
|
|
{
|
|
|
|
|
tree name = TREE_PURPOSE (a);
|
|
|
|
|
if (strcmp (IDENTIFIER_POINTER (name), "aligned") == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (a == NULL)
|
|
|
|
|
for (a = * prefix; a; a = TREE_CHAIN (a))
|
|
|
|
|
{
|
|
|
|
|
tree name = TREE_PURPOSE (a);
|
|
|
|
|
if (strcmp (IDENTIFIER_POINTER (name), "aligned") == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (a == NULL)
|
|
|
|
|
{
|
|
|
|
|
* attributes = tree_cons
|
|
|
|
|
(get_identifier ("aligned"),
|
|
|
|
|
tree_cons (NULL,
|
|
|
|
|
build_int_2 (maximum_field_alignment / 8, 0),
|
|
|
|
|
NULL),
|
|
|
|
|
* attributes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif /* HANDLE_PRAGMA_PACK_PUSH_POP */
|
|
|
|
|
|
|
|
|
|
/* Handle one token of a pragma directive. TOKEN is the current token, and
|
|
|
|
|
STRING is its printable form. Some front ends do not support generating
|
|
|
|
|
tokens, and will only pass in a STRING. Also some front ends will reuse
|
|
|
|
|
the buffer containing STRING, so it must be copied to a local buffer if
|
|
|
|
|
it needs to be preserved.
|
|
|
|
|
|
|
|
|
|
If STRING is non-NULL, then the return value will be ignored, and there
|
|
|
|
|
will be futher calls to handle_pragma_token() in order to handle the rest of
|
|
|
|
|
the line containing the #pragma directive. If STRING is NULL, the entire
|
|
|
|
|
line has now been presented to handle_pragma_token() and the return value
|
|
|
|
|
should be zero if the pragma flawed in some way, or if the pragma was not
|
|
|
|
|
recognised, and non-zero if it was successfully handled. */
|
1992-06-29 23:11:04 -04:00
|
|
|
|
|
1998-09-02 05:59:57 -04:00
|
|
|
|
int
|
1992-06-29 23:11:04 -04:00
|
|
|
|
handle_pragma_token (string, token)
|
bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.h (bitmap_print): Likewise.
* c-decl.c (builtin_function, grokdeclarator, grokfield): Likewise.
* c-lang.c (build_objc_string): Likewise.
* c-lex.c (yyerror, extend_token_buffer): Likewise. Don't include
limits.h or ctype.h. Remove unused variable `p'.
* c-lex.h (yyerror): Qualify a char* with the `const' keyword.
* c-pragma.c (handle_pragma_token): Likewise.
* c-pragma.h (handle_pragma_token): Likewise.
* c-tree.h (build_objc_string, builtin_function, grokfield,
build_indirect_ref, lvalue_or_else, readonly_warning, error_init,
pedwarn_init): Likewise.
* c-typeck.c (convert_for_assignment, warn_for_assignment,
push_string, warning_init, incomplete_type_error,
build_indirect_ref, lvalue_or_else, readonly_warning,
build_c_cast, spelling, push_member_name, print_spelling,
error_init, pedwarn_init, start_init): Likewise.
* objc/objc-act.c (build_objc_string): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* tree.h (lvalue_or_else, print_node, print_node_brief): Likewise.
From-SVN: r25296
1999-02-18 15:38:48 -05:00
|
|
|
|
const char * string;
|
1992-06-29 23:11:04 -04:00
|
|
|
|
tree token;
|
|
|
|
|
{
|
1998-10-01 06:50:15 -04:00
|
|
|
|
static enum pragma_state state = ps_start;
|
|
|
|
|
static enum pragma_state type;
|
|
|
|
|
static char * name;
|
|
|
|
|
static char * value;
|
1992-06-29 23:11:04 -04:00
|
|
|
|
static int align;
|
1999-04-26 17:18:08 -04:00
|
|
|
|
static tree id;
|
1992-06-29 23:11:04 -04:00
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
/* If we have reached the end of the #pragma directive then
|
|
|
|
|
determine what value we should return. */
|
|
|
|
|
|
1998-09-02 05:59:57 -04:00
|
|
|
|
if (string == NULL)
|
1992-06-29 23:11:04 -04:00
|
|
|
|
{
|
1998-10-01 06:50:15 -04:00
|
|
|
|
int ret_val = 0;
|
|
|
|
|
|
|
|
|
|
switch (type)
|
1992-06-29 23:11:04 -04:00
|
|
|
|
{
|
1998-10-01 06:50:15 -04:00
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_done:
|
|
|
|
|
/* The pragma was not recognised. */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
#ifdef HANDLE_PRAGMA_PACK
|
|
|
|
|
case ps_pack:
|
1992-06-29 23:11:04 -04:00
|
|
|
|
if (state == ps_right)
|
1998-09-02 05:59:57 -04:00
|
|
|
|
{
|
1998-10-01 06:50:15 -04:00
|
|
|
|
maximum_field_alignment = align * 8;
|
|
|
|
|
ret_val = 1;
|
1998-09-02 05:59:57 -04:00
|
|
|
|
}
|
1998-10-01 06:50:15 -04:00
|
|
|
|
else
|
|
|
|
|
warning ("malformed `#pragma pack'");
|
|
|
|
|
break;
|
|
|
|
|
#endif /* HANDLE_PRAGMA_PACK */
|
|
|
|
|
|
|
|
|
|
#ifdef HANDLE_PRAGMA_PACK_PUSH_POP
|
|
|
|
|
case ps_push:
|
|
|
|
|
if (state == ps_right)
|
1999-04-26 17:18:08 -04:00
|
|
|
|
ret_val = push_alignment (align, id);
|
1998-10-01 06:50:15 -04:00
|
|
|
|
else
|
1999-04-26 17:18:08 -04:00
|
|
|
|
warning ("malformed '#pragma pack(push[,id],<n>)'");
|
1998-10-01 06:50:15 -04:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_pop:
|
|
|
|
|
if (state == ps_right)
|
1999-04-26 17:18:08 -04:00
|
|
|
|
ret_val = pop_alignment (id);
|
1998-10-01 06:50:15 -04:00
|
|
|
|
else
|
1999-04-26 17:18:08 -04:00
|
|
|
|
warning ("malformed '#pragma pack(pop[,id])'");
|
1998-10-01 06:50:15 -04:00
|
|
|
|
break;
|
|
|
|
|
#endif /* HANDLE_PRAGMA_PACK_PUSH_POP */
|
|
|
|
|
|
1992-07-01 08:58:09 -04:00
|
|
|
|
#ifdef HANDLE_PRAGMA_WEAK
|
1998-10-01 06:50:15 -04:00
|
|
|
|
case ps_weak:
|
1992-07-01 08:58:09 -04:00
|
|
|
|
if (HANDLE_PRAGMA_WEAK)
|
1998-10-01 06:50:15 -04:00
|
|
|
|
{
|
|
|
|
|
if (state == ps_name)
|
|
|
|
|
ret_val = add_weak (name, NULL);
|
|
|
|
|
else if (state == ps_value)
|
|
|
|
|
ret_val = add_weak (name, value);
|
|
|
|
|
else
|
|
|
|
|
warning ("malformed `#pragma weak'");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ret_val = 1; /* Ignore the pragma. */
|
|
|
|
|
break;
|
1997-12-21 10:24:48 -05:00
|
|
|
|
#endif /* HANDLE_PRAGMA_WEAK */
|
1992-06-29 23:11:04 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type = state = ps_start;
|
1999-04-26 17:18:08 -04:00
|
|
|
|
id = NULL_TREE;
|
1998-09-02 05:59:57 -04:00
|
|
|
|
|
|
|
|
|
return ret_val;
|
1992-06-29 23:11:04 -04:00
|
|
|
|
}
|
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
/* If we have been given a token, but it is not an identifier,
|
|
|
|
|
or a small constant, then something has gone wrong. */
|
|
|
|
|
if (token)
|
|
|
|
|
{
|
|
|
|
|
switch (TREE_CODE (token))
|
|
|
|
|
{
|
|
|
|
|
case IDENTIFIER_NODE:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case INTEGER_CST:
|
|
|
|
|
if (TREE_INT_CST_HIGH (token) != 0)
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-06-29 23:11:04 -04:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ps_start:
|
1998-10-01 06:50:15 -04:00
|
|
|
|
type = state = ps_done;
|
|
|
|
|
#ifdef HANDLE_PRAGMA_PACK
|
|
|
|
|
if (strcmp (string, "pack") == 0)
|
|
|
|
|
type = state = ps_pack;
|
|
|
|
|
#endif
|
1998-09-02 05:59:57 -04:00
|
|
|
|
#ifdef HANDLE_PRAGMA_WEAK
|
1998-10-01 06:50:15 -04:00
|
|
|
|
if (strcmp (string, "weak") == 0)
|
|
|
|
|
type = state = ps_weak;
|
1998-09-02 05:59:57 -04:00
|
|
|
|
#endif
|
1992-06-29 23:11:04 -04:00
|
|
|
|
break;
|
1998-09-02 05:59:57 -04:00
|
|
|
|
|
|
|
|
|
#ifdef HANDLE_PRAGMA_WEAK
|
1992-06-29 23:11:04 -04:00
|
|
|
|
case ps_weak:
|
1998-10-01 06:50:15 -04:00
|
|
|
|
name = permalloc (strlen (string) + 1);
|
|
|
|
|
if (name == NULL)
|
1992-06-29 23:11:04 -04:00
|
|
|
|
{
|
1998-10-01 06:50:15 -04:00
|
|
|
|
warning ("Out of memory parsing #pragma weak");
|
|
|
|
|
state = ps_bad;
|
1992-06-29 23:11:04 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
1998-10-01 06:50:15 -04:00
|
|
|
|
{
|
|
|
|
|
strcpy (name, string);
|
|
|
|
|
state = ps_name;
|
|
|
|
|
}
|
1992-06-29 23:11:04 -04:00
|
|
|
|
break;
|
1998-09-02 05:59:57 -04:00
|
|
|
|
|
1992-06-29 23:11:04 -04:00
|
|
|
|
case ps_name:
|
|
|
|
|
state = (strcmp (string, "=") ? ps_bad : ps_equals);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_equals:
|
1998-10-01 06:50:15 -04:00
|
|
|
|
value = permalloc (strlen (string) + 1);
|
|
|
|
|
if (value == NULL)
|
1992-06-29 23:11:04 -04:00
|
|
|
|
{
|
1998-10-01 06:50:15 -04:00
|
|
|
|
warning ("Out of memory parsing #pragma weak");
|
|
|
|
|
state = ps_bad;
|
1992-06-29 23:11:04 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
1998-10-01 06:50:15 -04:00
|
|
|
|
{
|
|
|
|
|
strcpy (value, string);
|
|
|
|
|
state = ps_value;
|
|
|
|
|
}
|
1992-06-29 23:11:04 -04:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_value:
|
|
|
|
|
state = ps_bad;
|
|
|
|
|
break;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#endif /* HANDLE_PRAGMA_WEAK */
|
|
|
|
|
|
|
|
|
|
#ifdef HANDLE_PRAGMA_PACK
|
1992-06-29 23:11:04 -04:00
|
|
|
|
case ps_pack:
|
1998-10-01 06:50:15 -04:00
|
|
|
|
state = (strcmp (string, "(") ? ps_bad : ps_left);
|
1992-06-29 23:11:04 -04:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_left:
|
1998-10-11 17:05:04 -04:00
|
|
|
|
|
1999-04-26 17:18:08 -04:00
|
|
|
|
if (token == NULL_TREE)
|
1999-06-08 22:16:12 -04:00
|
|
|
|
{
|
|
|
|
|
/* #pragma pack () resets packing rules to their
|
|
|
|
|
defaults. */
|
|
|
|
|
if (strcmp (string, ")") == 0)
|
|
|
|
|
{
|
|
|
|
|
align = 0;
|
|
|
|
|
state = ps_right;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
state = ps_bad;
|
|
|
|
|
}
|
1999-04-26 17:18:08 -04:00
|
|
|
|
else if (TREE_CODE (token) == INTEGER_CST)
|
|
|
|
|
goto handle_align;
|
|
|
|
|
|
|
|
|
|
#ifdef HANDLE_PRAGMA_PACK_PUSH_POP
|
|
|
|
|
else if (TREE_CODE (token) == IDENTIFIER_NODE)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (string, "push") == 0)
|
|
|
|
|
type = state = ps_push;
|
|
|
|
|
else if (strcmp (string, "pop") == 0)
|
|
|
|
|
type = state = ps_pop;
|
|
|
|
|
else
|
|
|
|
|
state = ps_bad;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
1998-10-11 17:05:04 -04:00
|
|
|
|
else
|
1999-04-26 17:18:08 -04:00
|
|
|
|
state = ps_bad;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
handle_align:
|
|
|
|
|
align = TREE_INT_CST_LOW (token);
|
1998-10-01 06:50:15 -04:00
|
|
|
|
switch (align)
|
1992-06-29 23:11:04 -04:00
|
|
|
|
{
|
1998-10-01 06:50:15 -04:00
|
|
|
|
case 1:
|
|
|
|
|
case 2:
|
|
|
|
|
case 4:
|
1999-04-26 17:18:08 -04:00
|
|
|
|
case 8:
|
|
|
|
|
case 16:
|
1998-10-01 06:50:15 -04:00
|
|
|
|
state = ps_align;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
state = ps_bad;
|
|
|
|
|
break;
|
1992-06-29 23:11:04 -04:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_align:
|
1998-10-01 06:50:15 -04:00
|
|
|
|
state = (strcmp (string, ")") ? ps_bad : ps_right);
|
1992-06-29 23:11:04 -04:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_right:
|
|
|
|
|
state = ps_bad;
|
|
|
|
|
break;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#endif /* HANDLE_PRAGMA_PACK */
|
1992-06-29 23:11:04 -04:00
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#ifdef HANDLE_PRAGMA_PACK_PUSH_POP
|
|
|
|
|
case ps_push:
|
1999-04-26 17:18:08 -04:00
|
|
|
|
state = (strcmp (string, ",") ? ps_bad : ps_pushcomma);
|
1998-10-01 06:50:15 -04:00
|
|
|
|
break;
|
|
|
|
|
|
1999-04-26 17:18:08 -04:00
|
|
|
|
case ps_pushid:
|
|
|
|
|
state = (strcmp (string, ",") ? ps_bad : ps_pushcomma2);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_pushcomma:
|
|
|
|
|
if (token && TREE_CODE (token) == IDENTIFIER_NODE)
|
|
|
|
|
{
|
|
|
|
|
id = token;
|
|
|
|
|
state = ps_pushid;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* else fall through */
|
|
|
|
|
case ps_pushcomma2:
|
|
|
|
|
if (token && TREE_CODE (token) == INTEGER_CST)
|
|
|
|
|
goto handle_align;
|
|
|
|
|
else
|
|
|
|
|
state = ps_bad;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_pop:
|
|
|
|
|
if (strcmp (string, ",") == 0)
|
|
|
|
|
state = ps_popcomma;
|
|
|
|
|
else
|
|
|
|
|
state = (strcmp (string, ")") ? ps_bad : ps_right);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ps_popcomma:
|
|
|
|
|
if (token && TREE_CODE (token) == IDENTIFIER_NODE)
|
|
|
|
|
{
|
|
|
|
|
id = token;
|
|
|
|
|
state = ps_align;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
state = ps_bad;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
break;
|
|
|
|
|
#endif /* HANDLE_PRAGMA_PACK_PUSH_POP */
|
|
|
|
|
|
1992-06-29 23:11:04 -04:00
|
|
|
|
case ps_bad:
|
|
|
|
|
case ps_done:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
1998-09-02 05:59:57 -04:00
|
|
|
|
|
|
|
|
|
return 1;
|
1992-06-29 23:11:04 -04:00
|
|
|
|
}
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#endif /* HANDLE_GENERIC_PRAGMAS */
|