Index: lib/MC/MCExpr.cpp =================================================================== --- lib/MC/MCExpr.cpp +++ lib/MC/MCExpr.cpp @@ -754,6 +754,7 @@ case MCBinaryExpr::Add: Result = LHS + RHS; break; case MCBinaryExpr::And: Result = LHS & RHS; break; case MCBinaryExpr::Div: + case MCBinaryExpr::Mod: // Handle division by zero. gas just emits a warning and keeps going, // we try to be stricter. // FIXME: Currently the caller of this function has no way to understand @@ -762,7 +763,10 @@ // change this code to emit a better diagnostic. if (RHS == 0) return false; - Result = LHS / RHS; + if (ABE->getOpcode() == MCBinaryExpr::Div) + Result = LHS / RHS; + else + Result = LHS % RHS; break; case MCBinaryExpr::EQ: Result = LHS == RHS; break; case MCBinaryExpr::GT: Result = LHS > RHS; break; @@ -772,7 +776,6 @@ case MCBinaryExpr::LShr: Result = uint64_t(LHS) >> uint64_t(RHS); break; case MCBinaryExpr::LT: Result = LHS < RHS; break; case MCBinaryExpr::LTE: Result = LHS <= RHS; break; - case MCBinaryExpr::Mod: Result = LHS % RHS; break; case MCBinaryExpr::Mul: Result = LHS * RHS; break; case MCBinaryExpr::NE: Result = LHS != RHS; break; case MCBinaryExpr::Or: Result = LHS | RHS; break; Index: test/MC/ELF/div-by-zero.s =================================================================== --- test/MC/ELF/div-by-zero.s +++ test/MC/ELF/div-by-zero.s @@ -4,3 +4,6 @@ // CHECK: expected relocatable expression .int 1/0 + +// CHECK: expected relocatable expression +.int 2%0