master
Josh Wolfe 2017-09-20 21:47:43 -07:00
parent 4c8443d96d
commit 0827a8f36b
2 changed files with 17 additions and 2 deletions

View File

@ -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;

View File

@ -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)