[PATCH 2/3] extract apply_bitwise() from declaration_specifiers()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No functional changes here, just preparing the next patch.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 parse.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/parse.c b/parse.c
index bb504d21a..ce96289c5 100644
--- a/parse.c
+++ b/parse.c
@@ -641,6 +641,29 @@ static void apply_modifiers(struct position pos, struct decl_state *ctx)
 	
 }
 
+static struct symbol *apply_bitwise(struct position pos, struct ctype *ctx)
+{
+	struct symbol *old = ctx->base_type;
+	struct symbol *type;
+
+	if (!(ctx->modifiers & MOD_BITWISE))
+		return old;
+
+	ctx->modifiers &= ~MOD_BITWISE;
+	if (!is_int_type(old)) {
+		sparse_error(pos, "invalid modifier");
+		return old;
+	}
+	type = alloc_symbol(pos, SYM_BASETYPE);
+	*type = *ctx->base_type;
+	type->ctype.modifiers &= ~MOD_SPECIFIER;
+	type->ctype.base_type = old;
+	type->type = SYM_RESTRICT;
+	ctx->base_type = type;
+	create_fouled(type);
+	return type;
+}
+
 static struct symbol * alloc_indirect_symbol(struct position pos, struct ctype *ctype, int type)
 {
 	struct symbol *sym = alloc_symbol(pos, type);
@@ -1543,21 +1566,9 @@ static struct token *declaration_specifiers(struct token *token, struct decl_sta
 		ctx->ctype.base_type = base;
 	}
 
-	if (ctx->ctype.modifiers & MOD_BITWISE) {
-		struct symbol *type;
-		ctx->ctype.modifiers &= ~MOD_BITWISE;
-		if (!is_int_type(ctx->ctype.base_type)) {
-			sparse_error(token->pos, "invalid modifier");
-			return token;
-		}
-		type = alloc_symbol(token->pos, SYM_BASETYPE);
-		*type = *ctx->ctype.base_type;
-		type->ctype.modifiers &= ~MOD_SPECIFIER;
-		type->ctype.base_type = ctx->ctype.base_type;
-		type->type = SYM_RESTRICT;
-		ctx->ctype.base_type = type;
-		create_fouled(type);
-	}
+	if (ctx->ctype.modifiers & MOD_BITWISE)
+		apply_bitwise(token->pos, &ctx->ctype);
+
 	return token;
 }
 
-- 
2.16.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux