From 0a2ea1a773c54c3a4b02edfeb19123aa4224c735 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 3 Nov 2019 11:36:39 +0800 Subject: Codegen C - Fix compilation errors on MSVC (and some warnings on GCC) --- src/trans/codegen_c.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/trans/codegen_c.cpp') diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index 631db28b..33e0bbbf 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -2191,13 +2191,20 @@ namespace { MIR_TODO(*m_mir_res, "Handle BorrowData (emit_literal) - " << *e); ), (String, - m_of << "{ "; + bool is_slice + = TU_TEST2(ty.m_data, Borrow, .inner->m_data, Primitive, == HIR::CoreType::Str) + || TU_TEST1(ty.m_data, Borrow, .inner->m_data.is_Slice()) + ; + bool is_wrapped = is_slice + || ty.m_data.is_Array() + ; + if( is_wrapped ) + m_of << "{ "; this->print_escaped_string(e); - // TODO: Better type checking? - if( !ty.m_data.is_Array() ) { + if( is_slice ) m_of << ", " << e.size(); - } - m_of << "}"; + if( is_wrapped ) + m_of << "}"; ) ) } -- cgit v1.2.3