Skip to content

Commit

Permalink
parsec supports C NULL to pointer implicit cast
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoshwolfe committed Nov 14, 2017
1 parent a890380 commit 1f28fcd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/parsec.cpp
Expand Up @@ -1267,6 +1267,8 @@ static AstNode *trans_implicit_cast_expr(Context *c, AstNode *block, ImplicitCas
node->data.fn_call_expr.params.append(target_node);
return node;
}
case CK_NullToPointer:
return trans_create_node(c, NodeTypeNullLiteral);
case CK_Dependent:
emit_warning(c, stmt->getLocStart(), "TODO handle C translation cast CK_Dependent");
return nullptr;
Expand All @@ -1291,9 +1293,6 @@ static AstNode *trans_implicit_cast_expr(Context *c, AstNode *block, ImplicitCas
case CK_ToUnion:
emit_warning(c, stmt->getLocStart(), "TODO handle C translation cast CK_ToUnion");
return nullptr;
case CK_NullToPointer:
emit_warning(c, stmt->getLocStart(), "TODO handle C translation cast CK_NullToPointer");
return nullptr;
case CK_NullToMemberPointer:
emit_warning(c, stmt->getLocStart(), "TODO handle C translation cast CK_NullToMemberPointer");
return nullptr;
Expand Down
10 changes: 10 additions & 0 deletions test/parsec.zig
Expand Up @@ -596,6 +596,16 @@ pub fn addCases(cases: &tests.ParseCContext) {
\\ return @sizeOf(c_int);
\\}
);

cases.addC("null pointer implicit cast",
\\int* foo(void) {
\\ return 0;
\\}
,
\\export fn foo() -> ?&c_int {
\\ return null;
\\}
);
}


Expand Down

0 comments on commit 1f28fcd

Please sign in to comment.