diff mbox series

[10/10] keyword type is a bitmask and must be tested so

Message ID 20200809205329.42811-11-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
The keyword's type is a bitmask because depending on the context
the same keyword can be of different type (for example 'const'
as qualifier and the attribute 'const' , a variant of 'pure').

Thus, it's an error to test this type for equality, instead it's
a specific (set of) bit(s) that must be tested.

So, change a test ' x == KW_...' into 'x & KW_...'.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/parse.c b/parse.c
index d378f1255fee..e1a5cce4e46b 100644
--- a/parse.c
+++ b/parse.c
@@ -1287,7 +1287,7 @@  static struct token *attribute_mode(struct token *token, struct symbol *attr, st
 	token = expect(token, '(', "after mode attribute");
 	if (token_type(token) == TOKEN_IDENT) {
 		struct symbol *mode = lookup_keyword(token->ident, NS_KEYWORD);
-		if (mode && mode->op->type == KW_MODE)
+		if (mode && mode->op->type & KW_MODE)
 			ctx->mode = mode->op;
 		else
 			sparse_error(token->pos, "unknown mode attribute %s", show_ident(token->ident));