authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-09-20 21:47:43-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-09-20 21:47:43-07:00
log0827a8f36bd0b99b876586b8c7ee099fbc903535
tree660fe754ecda2e6d57b6cbc63f8edbd71f96ed1c
parent4c8443d96db4a441b393ea0c3c8d76a7493f46d0

==, !=


2 files changed, 17 insertions(+), 2 deletions(-)

src/parsec.cpp+1-2
...@@ -978,8 +978,7 @@ static AstNode *trans_binary_operator(Context *c, bool result_used, AstNode *blo...@@ -978,8 +978,7 @@ static AstNode *trans_binary_operator(Context *c, bool result_used, AstNode *blo
978 case BO_EQ:978 case BO_EQ:
979 return trans_create_bin_op(c, block, stmt->getLHS(), BinOpTypeCmpEq, stmt->getRHS());979 return trans_create_bin_op(c, block, stmt->getLHS(), BinOpTypeCmpEq, stmt->getRHS());
980 case BO_NE:980 case BO_NE:
981 emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_NE");981 return trans_create_bin_op(c, block, stmt->getLHS(), BinOpTypeCmpNotEq, stmt->getRHS());
982 return nullptr;
983 case BO_And:982 case BO_And:
984 emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_And");983 emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_And");
985 return nullptr;984 return nullptr;
test/parsec.zig+16
...@@ -373,6 +373,22 @@ pub fn addCases(cases: &tests.ParseCContext) {...@@ -373,6 +373,22 @@ pub fn addCases(cases: &tests.ParseCContext) {
373 \\}373 \\}
374 );374 );
375375
376 cases.add("==, !=",
377 \\int max(int a, int b) {
378 \\ if (a == b)
379 \\ return a;
380 \\ if (a != b)
381 \\ return b;
382 \\ return a;
383 \\}
384 ,
385 \\export fn max(a: c_int, b: c_int) -> c_int {
386 \\ if (a == b) return a;
387 \\ if (a != b) return b;
388 \\ return a;
389 \\}
390 );
391
376 cases.add("logical and, logical or",392 cases.add("logical and, logical or",
377 \\int max(int a, int b) {393 \\int max(int a, int b) {
378 \\ if (a < b || a == b)394 \\ if (a < b || a == b)