diff options
author | John Hodge <tpg@mutabah.net> | 2017-01-01 15:16:22 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-01-01 15:16:22 +0800 |
commit | 4cd46a298c6611dd169eeae3ef7412f0c3af3289 (patch) | |
tree | d6d00dfb7d39e5294b9387c847ae501411d214c6 /src/trans/codegen_c.cpp | |
parent | 458689c8dca06be05b0adbfe9167a2e2d631745f (diff) | |
download | mrust-4cd46a298c6611dd169eeae3ef7412f0c3af3289.tar.gz |
Codegen C - Handle function pointers cast to raw pointers in literals
Diffstat (limited to 'src/trans/codegen_c.cpp')
-rw-r--r-- | src/trans/codegen_c.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index 3bd8d475..82b78dd8 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -584,9 +584,25 @@ namespace { m_of << e; ), (BorrowOf, - // TODO: Get the pointed-to item type - if( ! ty.m_data.is_Function() ) + TU_MATCHA( (e.m_data), (pe), + (Generic, + if( ! m_crate.get_valitem_by_path(sp, pe.m_path).is_Function() ) + m_of << "&"; + else if( !ty.m_data.is_Function() ) // TODO: Ensure that the type is `*const ()` or similar. + m_of << "(void*)"; + else + ; + ), + (UfcsUnknown, + MIR_BUG(*m_mir_res, "UfcsUnknown in trans " << e); + ), + (UfcsInherent, m_of << "&"; + ), + (UfcsKnown, + m_of << "&"; + ) + ) m_of << Trans_Mangle( params.monomorph(m_resolve, e)); ), (String, |