translate-c: fix clobbering primitive types

This commit is contained in:
Andrew Kelley 2017-11-28 03:17:28 -05:00
parent 8d5c4a67a7
commit 26096e79d1
2 changed files with 13 additions and 0 deletions

View File

@ -400,6 +400,9 @@ static AstNode *get_global(Context *c, Buf *name) {
if (entry)
return entry->value;
}
if (c->codegen->primitive_type_table.maybe_get(name) != nullptr) {
return trans_create_node_symbol(c, name);
}
return nullptr;
}

View File

@ -1162,4 +1162,14 @@ pub fn addCases(cases: &tests.TranslateCContext) {
\\ return ~x;
\\}
);
cases.add("primitive types included in defined symbols",
\\int foo(int u32) {
\\ return u32;
\\}
,
\\pub fn foo(u32_0: c_int) -> c_int {
\\ return u32_0;
\\}
);
}