==, !=
parent
4c8443d96d
commit
0827a8f36b
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue