From d81362ff6af4fd4fbd9aeacfd50283b490b6c7ce Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 27 Aug 2022 07:18:06 +0200 Subject: improve bitfields --- src/parse.cff | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/parse.cff') diff --git a/src/parse.cff b/src/parse.cff index 364b23b..b978f4b 100644 --- a/src/parse.cff +++ b/src/parse.cff @@ -1676,10 +1676,6 @@ fn pexpostfix(P *Parser) Expr { if ex.ty.konst { err(P, ex.loc, "left operand to prefix %qT operator is const", tok); } - if ex.u.#tag == :BitDot { - err(P, ex.loc, "cannot apply post-%srement operator to bitfield value", - tok.t == '++' ? "inc" : "dec"); - } ex = { tok.loc, ex.ty, .u: :UnOp { tok.t == '++' ? :postinc : :postdec, exprdup(P.alloc, ex) @@ -1882,10 +1878,6 @@ fn pexprefix(P *Parser) Expr { if ex.ty.konst { err(P, ex.loc, "left operand to prefix %qT operator is const", tok); } - if ex.u.#tag == :BitDot { - err(P, ex.loc, "cannot apply pre-%srement operator to bitfield value", - tok.t == '++' ? "inc" : "dec"); - } return { tok.loc, ex.ty, .u: :UnOp { tok.t == '++' ? :preinc : :predec, exprdup(P.alloc, ex) @@ -1916,6 +1908,9 @@ fn pexprefix(P *Parser) Expr { and !(ex.u.#tag == :ZeroIni or ex.u.#tag == :AggIni or ex.u.#tag == :ArrIni) { err(P, ex.loc, "invalid operand to `&': not an lvalue"); } + if ex.u.#tag == :BitDot { + err(P, ex.loc, "cannot take address of bitfield value"); + } return { tok.loc, ty2, .u: :UnOp { :addrof, exprdup(P.alloc, ex) }}; case lexmatch(P, &tok, :kw_as); @@ -2142,8 +2137,6 @@ fn pexassign(P *Parser) Expr { err(P, ex.loc, "operands %t and %t to assignment operator %qT have incompatible types", ex.ty, rhs.ty, tok); - case okind != :Set and ex.u.#tag == :BitDot; - err(P, ex.loc, "cannot apply compound assignment operator to bitfield value"); case ex.ty.konst; err(P, ex.loc, "left operand to assignment is const"); } -- cgit v1.2.3