Skip to contentSkip to conversation

preparations to ->declarator() cleanup - separate typedef handling

PATCH New Al Viro 1 participant 1 message Mar 9, 2009 Sparse checker

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 10/18 preparations to ->declarator() cleanup - separate typedef handling

Take typedef handling in declaration_specifiers() into separate branch; kill useless check for qual in case the type we've got has non-NULL base_type (we'd have already buggered off in that situation before we get to the check in question).

---
 parse.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
parse.c +11 -9
index 1435fde..ba1a52d 100644
@@ -1105,29 +1105,31 @@ static struct token *declaration_specifiers(struct token *next, struct decl_stat
 		s = lookup_symbol(ident, NS_TYPEDEF);
 		if (!s)
 			break;
-		thistype = s->ctype;
-		mod = thistype.modifiers;
 		if (qual) {
 			if (s->type != SYM_KEYWORD)
 				break;
 			if (!(s->op->type & (KW_ATTRIBUTE | KW_QUALIFIER)))
 				break;
 		}
+		if (s->ctype.modifiers & MOD_USERTYPE) {
+			if (ctx->ctype.base_type)
+				break;
+			if (ctx->ctype.modifiers & MOD_SPECIFIER)
+				break;
+			ctx->ctype.base_type = s->ctype.base_type;
+			apply_ctype(token->pos, &s->ctype, &ctx->ctype);
+			continue;
+		}
+		thistype = s->ctype;
+		mod = thistype.modifiers;
 		if (s->type == SYM_KEYWORD && s->op->declarator) {
 			next = s->op->declarator(next, &thistype);
 			mod = thistype.modifiers;
 		}
 		type = thistype.base_type;
 		if (type) {
-			if (qual)
-				break;
 			if (ctx->ctype.base_type)
 				break;
-			/* User types only mix with qualifiers */
-			if (mod & MOD_USERTYPE) {
-				if (ctx->ctype.modifiers & MOD_SPECIFIER)
-					break;
-			}
 			ctx->ctype.base_type = type;
 		}
 
Signature · 1 line
1.5.6.5