diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-09-11 04:29:58 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-09-11 04:29:58 +0000 |
commit | c9906f1e70916bbd20e66e9d92618dafc8dc67c8 (patch) | |
tree | 4519490ec505b7c1812e087ae63f6d7cee10cd60 /gcc/c-pragma.c | |
parent | 0e66aa759d3c9791dda9ca660fe13b6b2e78c126 (diff) | |
download | gcc-c9906f1e70916bbd20e66e9d92618dafc8dc67c8.tar.gz |
* c-pragma.c (handle_pragma_pack): Correct parsing logic so it
won't give a spurious error for '#pragma pack()'. Simplify
control flow for readability. 'reset' action is not necessary.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36308 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-pragma.c')
-rw-r--r-- | gcc/c-pragma.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index 5b8f4491cde..8503f3cacca 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -188,59 +188,57 @@ handle_pragma_pack (dummy) tree x, id = 0; int align; enum cpp_ttype token; - enum { set, reset, push, pop } action; + enum { set, push, pop } action; if (c_lex (&x) != CPP_OPEN_PAREN) BAD ("missing '(' after '#pragma pack' - ignored"); token = c_lex (&x); if (token == CPP_CLOSE_PAREN) - action = reset; + { + action = set; + align = 0; + } else if (token == CPP_NUMBER) { align = TREE_INT_CST_LOW (x); action = set; + if (c_lex (&x) != CPP_CLOSE_PAREN) + BAD ("malformed '#pragma pack' - ignored"); } else if (token == CPP_NAME) { - if (!strcmp (IDENTIFIER_POINTER (x), "push")) + const char *op = IDENTIFIER_POINTER (x); + if (!strcmp (op, "push")) action = push; - else if (!strcmp (IDENTIFIER_POINTER (x), "pop")) + else if (!strcmp (op, "pop")) action = pop; else - BAD2 ("unknown action '%s' for '#pragma pack' - ignored", - IDENTIFIER_POINTER (x)); - } - else - BAD ("malformed '#pragma pack' - ignored"); + BAD2 ("unknown action '%s' for '#pragma pack' - ignored", op); - token = c_lex (&x); - if ((action == set || action == reset) && token != CPP_CLOSE_PAREN) - BAD ("malformed '#pragma pack' - ignored"); - if ((action == push || action == pop) && token != CPP_COMMA) - BAD2 ("malformed '#pragma pack(%s[, id], <n>)' - ignored", - action == push ? "push" : "pop"); + if (c_lex (&x) != CPP_COMMA) + BAD2 ("malformed '#pragma pack(%s[, id], <n>)' - ignored", op); - if (action == push || action == pop) - { token = c_lex (&x); if (token == CPP_NAME) { id = x; if (c_lex (&x) != CPP_COMMA) - BAD2 ("malformed '#pragma pack(%s[, id], <n>)' - ignored", - action == push ? "push" : "pop"); + BAD2 ("malformed '#pragma pack(%s[, id], <n>)' - ignored", op); token = c_lex (&x); } + if (token == CPP_NUMBER) align = TREE_INT_CST_LOW (x); else - BAD2 ("malformed '#pragma pack(%s[, id], <n>)' - ignored", - action == push ? "push" : "pop"); + BAD2 ("malformed '#pragma pack(%s[, id], <n>)' - ignored", op); if (c_lex (&x) != CPP_CLOSE_PAREN) BAD ("malformed '#pragma pack' - ignored"); } + else + BAD ("malformed '#pragma pack' - ignored"); + if (c_lex (&x) != CPP_EOF) warning ("junk at end of '#pragma pack'"); @@ -261,7 +259,6 @@ handle_pragma_pack (dummy) switch (action) { case set: SET_GLOBAL_ALIGNMENT (align); break; - case reset: SET_GLOBAL_ALIGNMENT (0); break; case push: push_alignment (align, id); break; case pop: pop_alignment (id); break; } |