File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -1170,8 +1170,13 @@ bool ByteCodeExprGen<Emitter>::VisitCompoundAssignOperator(
11701170 }
11711171
11721172 // And store the result in LHS.
1173- if (DiscardResult)
1173+ if (DiscardResult) {
1174+ if (LHS->refersToBitField ())
1175+ return this ->emitStoreBitFieldPop (*ResultT, E);
11741176 return this ->emitStorePop (*ResultT, E);
1177+ }
1178+ if (LHS->refersToBitField ())
1179+ return this ->emitStoreBitField (*ResultT, E);
11751180 return this ->emitStore (*ResultT, E);
11761181}
11771182
Original file line number Diff line number Diff line change @@ -31,8 +31,6 @@ namespace Basic {
3131 return a.a = 10 ;
3232 }
3333 static_assert (storeA2() == 2 , " " );
34-
35- // TODO: +=, -=, etc. operators.
3634}
3735
3836namespace Overflow {
@@ -45,3 +43,39 @@ namespace Overflow {
4543
4644 static_assert (f() == 3 , " " );
4745}
46+
47+ namespace Compound {
48+ struct A {
49+ unsigned int a : 2 ;
50+ constexpr A () : a(0 ) {}
51+ constexpr A (int a) : a(a) {}
52+ };
53+
54+ constexpr unsigned add () {
55+ A a;
56+ a.a += 10 ;
57+ return a.a ;
58+ }
59+ static_assert (add() == 2 , " " );
60+
61+ constexpr unsigned sub () {
62+ A a;
63+ a.a -= 10 ;
64+ return a.a ;
65+ }
66+ static_assert (sub() == 2 , " " );
67+
68+ constexpr unsigned mul () {
69+ A a (1 );
70+ a.a *= 5 ;
71+ return a.a ;
72+ }
73+ static_assert (mul() == 1 , " " );
74+
75+ constexpr unsigned div () {
76+ A a (2 );
77+ a.a /= 2 ;
78+ return a.a ;
79+ }
80+ static_assert (div() == 1 , " " );
81+ }
You can’t perform that action at this time.
0 commit comments