From fb9b50ff9c63c2eefcef298348882fc3c2261587 Mon Sep 17 00:00:00 2001 From: Jesse Rosenstock Date: Wed, 29 Jul 2020 22:45:59 +0200 Subject: [PATCH] Move type checks before bit-field width parsing --- src/cc65/declare.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index b8ad09cfd..5c5c5c01e 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -688,16 +688,16 @@ static int ParseFieldWidth (Declaration* Decl) return -1; } - /* Read the width */ - NextToken (); - ConstAbsIntExpr (hie1, &Expr); - if (SizeOf (Decl->Type) != SizeOf (type_uint)) { /* Only int sized types may be used for bit-fields for now */ Error ("cc65 currently only supports unsigned int bit-fields"); return -1; } + /* Read the width */ + NextToken (); + ConstAbsIntExpr (hie1, &Expr); + if (Expr.IVal < 0) { Error ("Negative width in bit-field"); return -1;