mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
Implements translation for the prefix not operator (#628)
This commit is contained in:
parent
671183fa9a
commit
3e8fd24547
@ -1875,8 +1875,13 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc
|
||||
}
|
||||
}
|
||||
case UO_Not:
|
||||
emit_warning(c, stmt->getLocStart(), "TODO handle C translation UO_Not");
|
||||
return nullptr;
|
||||
{
|
||||
Expr *op_expr = stmt->getSubExpr();
|
||||
AstNode *sub_node = trans_expr(c, ResultUsedYes, scope, op_expr, TransRValue);
|
||||
if (sub_node == nullptr)
|
||||
return nullptr;
|
||||
return trans_create_node_prefix_op(c, PrefixOpBinNot, sub_node);
|
||||
}
|
||||
case UO_LNot:
|
||||
emit_warning(c, stmt->getLocStart(), "TODO handle C translation UO_LNot");
|
||||
return nullptr;
|
||||
|
||||
@ -1114,4 +1114,14 @@ pub fn addCases(cases: &tests.TranslateCContext) {
|
||||
\\ return @ptrCast(?&f32, a);
|
||||
\\}
|
||||
);
|
||||
|
||||
cases.add("bin not",
|
||||
\\int foo(int x) {
|
||||
\\ return ~x;
|
||||
\\}
|
||||
,
|
||||
\\pub fn foo(x: c_int) -> c_int {
|
||||
\\ return ~x;
|
||||
\\}
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user