From b67b8ddd38c5f974ef686c29fdf2798ac7f77faf Mon Sep 17 00:00:00 2001 From: acqn Date: Sun, 19 Jul 2020 21:23:20 +0800 Subject: [PATCH] Disabled applying 'sizeof' to bit-fields. --- src/cc65/expr.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index b05083323..0b668f402 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1898,14 +1898,19 @@ void hie10 (ExprDesc* Expr) CodeMark Mark; GetCodePos (&Mark); hie10 (Expr); - /* If the expression is a literal string, release it, so it - ** won't be output as data if not used elsewhere. - */ - if (ED_IsLocLiteral (Expr)) { - ReleaseLiteral (Expr->LVal); + if (ED_IsBitField (Expr)) { + Error ("Cannot apply 'sizeof' to bit-field"); + Size = 0; + } else { + /* If the expression is a literal string, release it, so it + ** won't be output as data if not used elsewhere. + */ + if (ED_IsLocLiteral (Expr)) { + ReleaseLiteral (Expr->LVal); + } + /* Calculate the size */ + Size = CheckedSizeOf (Expr->Type); } - /* Calculate the size */ - Size = CheckedSizeOf (Expr->Type); /* Remove any generated code */ RemoveCode (&Mark); }