From 0827a8f36bd0b99b876586b8c7ee099fbc903535 Mon Sep 17 00:00:00 2001 From: Josh Wolfe Date: Wed, 20 Sep 2017 21:47:43 -0700 Subject: [PATCH] ==, != --- src/parsec.cpp | 3 +-- test/parsec.zig | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) 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)