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(
1170
1170
}
1171
1171
1172
1172
// And store the result in LHS.
1173
- if (DiscardResult)
1173
+ if (DiscardResult) {
1174
+ if (LHS->refersToBitField ())
1175
+ return this ->emitStoreBitFieldPop (*ResultT, E);
1174
1176
return this ->emitStorePop (*ResultT, E);
1177
+ }
1178
+ if (LHS->refersToBitField ())
1179
+ return this ->emitStoreBitField (*ResultT, E);
1175
1180
return this ->emitStore (*ResultT, E);
1176
1181
}
1177
1182
Original file line number Diff line number Diff line change @@ -31,8 +31,6 @@ namespace Basic {
31
31
return a.a = 10 ;
32
32
}
33
33
static_assert (storeA2() == 2 , " " );
34
-
35
- // TODO: +=, -=, etc. operators.
36
34
}
37
35
38
36
namespace Overflow {
@@ -45,3 +43,39 @@ namespace Overflow {
45
43
46
44
static_assert (f() == 3 , " " );
47
45
}
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