diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-19 16:45:19 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-25 23:19:12 +0200 |
commit | f009179a05f74118549e4810c0681b4848e374d6 (patch) | |
tree | 8f19f9dbf418ea2ff913ba59a60fce5f2fd35769 | |
parent | 99f8202a62d33c76285a516aaec4aaefe9585223 (diff) | |
download | sparse-f009179a05f74118549e4810c0681b4848e374d6.tar.gz |
testing for SYM_KEYWORD is unneeded for lookup_keyword()
All symbols returned by lookup_keyword() are of type SYM_KEYWORD,
because either:
1) it's in NS_KEYWORD (and all symbol in NS_KEYWORD are SYM_KEYWORD)
2) it's in NS_TYPEDEF and all *keywords* in NS_TYPEDEF are reserved
and so can't be user defined and so must be SYM_KEYWORD.
It's thus unneeded to test it.
So, remove the unneeded test.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | parse.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -1620,8 +1620,6 @@ static struct token *handle_qualifiers(struct token *t, struct decl_state *ctx) struct symbol *s = lookup_keyword(t->ident, NS_TYPEDEF); if (!s) break; - if (s->type != SYM_KEYWORD) - break; if (!(s->op->type & (KW_ATTRIBUTE | KW_QUALIFIER))) break; t = t->next; @@ -1749,7 +1747,7 @@ static struct token *handle_asm_name(struct token *token, struct decl_state *ctx if (token_type(token) != TOKEN_IDENT) return token; keyword = lookup_keyword(token->ident, NS_KEYWORD); - if (!keyword || keyword->type != SYM_KEYWORD) + if (!keyword) return token; if (!(keyword->op->type & KW_ASM)) return token; @@ -1770,7 +1768,7 @@ static bool match_attribute(struct token *token) if (token_type(token) != TOKEN_IDENT) return false; sym = lookup_keyword(token->ident, NS_TYPEDEF); - if (!sym || sym->type != SYM_KEYWORD) + if (!sym) return false; return sym->op->type & KW_ATTRIBUTE; } |