File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -733,8 +733,8 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
733
733
}
734
734
735
735
// Typecheck the args.
736
- std::optional<PrimType> LT = classify (LHS-> getType () );
737
- std::optional<PrimType> RT = classify (RHS-> getType () );
736
+ std::optional<PrimType> LT = classify (LHS);
737
+ std::optional<PrimType> RT = classify (RHS);
738
738
std::optional<PrimType> T = classify (BO->getType ());
739
739
740
740
// Special case for C++'s three-way/spaceship operator <=>, which
@@ -769,8 +769,16 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
769
769
return this ->VisitPointerArithBinOp (BO);
770
770
}
771
771
772
- if (!visit (LHS) || !visit (RHS))
773
- return false ;
772
+ // Assignmentes require us to evalute the RHS first.
773
+ if (BO->getOpcode () == BO_Assign) {
774
+ if (!visit (RHS) || !visit (LHS))
775
+ return false ;
776
+ if (!this ->emitFlip (*LT, *RT, BO))
777
+ return false ;
778
+ } else {
779
+ if (!visit (LHS) || !visit (RHS))
780
+ return false ;
781
+ }
774
782
775
783
// For languages such as C, cast the result of one
776
784
// of our comparision opcodes to T (which is usually int).
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ namespace EvalOrder {
45
45
}
46
46
template <typename T> constexpr T &&b(T &&v) {
47
47
if (!done_a)
48
- throw " wrong" ; // expected-note 4 {{not valid}}
48
+ throw " wrong" ; // expected-note 3 {{not valid}}
49
49
done_b = true ;
50
50
return (T &&)v;
51
51
}
@@ -78,8 +78,7 @@ namespace EvalOrder {
78
78
SEQ (A(f)(B(1 ), B(2 ), B(3 )));
79
79
80
80
// Rule 5: b = a, b @= a
81
- SEQ (B(lvalue<int >().get()) = A(0 )); // expected-error {{not an integral constant expression}} FIXME \
82
- // expected-note 2{{in call to}}
81
+ SEQ (B(lvalue<int >().get()) = A(0 ));
83
82
SEQ (B(lvalue<UserDefined>().get()) = A(ud)); // expected-error {{not an integral constant expression}} FIXME \
84
83
// expected-note 2{{in call to}}
85
84
SEQ (B(lvalue<int >().get()) += A(0 ));
You can’t perform that action at this time.
0 commit comments