diff --git a/src/parsec.cpp b/src/parsec.cpp index 342b519b1..0c49cf30e 100644 --- a/src/parsec.cpp +++ b/src/parsec.cpp @@ -978,8 +978,7 @@ static AstNode *trans_binary_operator(Context *c, bool result_used, AstNode *blo case BO_EQ: return trans_create_bin_op(c, block, stmt->getLHS(), BinOpTypeCmpEq, stmt->getRHS()); case BO_NE: - emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_NE"); - return nullptr; + return trans_create_bin_op(c, block, stmt->getLHS(), BinOpTypeCmpNotEq, stmt->getRHS()); case BO_And: emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_And"); return nullptr; diff --git a/test/parsec.zig b/test/parsec.zig index a30cb067b..0027903f3 100644 --- a/test/parsec.zig +++ b/test/parsec.zig @@ -373,6 +373,22 @@ pub fn addCases(cases: &tests.ParseCContext) { \\} ); + cases.add("==, !=", + \\int max(int a, int b) { + \\ if (a == b) + \\ return a; + \\ if (a != b) + \\ return b; + \\ return a; + \\} + , + \\export fn max(a: c_int, b: c_int) -> c_int { + \\ if (a == b) return a; + \\ if (a != b) return b; + \\ return a; + \\} + ); + cases.add("logical and, logical or", \\int max(int a, int b) { \\ if (a < b || a == b)