diff mbox series

[08/10] testing for SYM_KEYWORD is unneeded for lookup_keyword()

Message ID 20200809205329.42811-9-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series separate parsing of asm-names from attributes | expand

Commit Message

Luc Van Oostenryck Aug. 9, 2020, 8:53 p.m. UTC
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>
---
 parse.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/parse.c b/parse.c
index f2fdbc9b5a7b..2b7ef2ae23c4 100644
--- a/parse.c
+++ b/parse.c
@@ -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;
 }