From: Zack Weinberg Date: Mon, 11 Sep 2000 04:29:58 +0000 (+0000) Subject: c-pragma.c (handle_pragma_pack): Correct parsing logic so it won't give a spurious... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4337bc937caa26789f01e16d3eaa7ddd72c9558a;p=platform%2Fupstream%2Fgcc.git c-pragma.c (handle_pragma_pack): Correct parsing logic so it won't give a spurious error for '#pragma pack()'. * 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. From-SVN: r36308 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0b0bca6..5f7a72a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2000-09-10 Zack Weinberg + * 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. + +2000-09-10 Zack Weinberg + * defaults.h: Provide default definitions for: CHAR_TYPE_SIZE, SHORT_TYPE_SIZE, INT_TYPE_SIZE, LONG_TYPE_SIZE, LONG_LONG_TYPE_SIZE, WCHAR_TYPE_SIZE, FLOAT_TYPE_SIZE, diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index 5b8f449..8503f3c 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], )' - ignored", - action == push ? "push" : "pop"); + if (c_lex (&x) != CPP_COMMA) + BAD2 ("malformed '#pragma pack(%s[, id], )' - 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], )' - ignored", - action == push ? "push" : "pop"); + BAD2 ("malformed '#pragma pack(%s[, id], )' - ignored", op); token = c_lex (&x); } + if (token == CPP_NUMBER) align = TREE_INT_CST_LOW (x); else - BAD2 ("malformed '#pragma pack(%s[, id], )' - ignored", - action == push ? "push" : "pop"); + BAD2 ("malformed '#pragma pack(%s[, id], )' - 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; }