Fix casting issues (missing func_vt in riscvgen.c):
When compiling a file like: long cast_charp_to_long (char const *i) { return (long)i; } long cast_int_to_long (int i) { return (long)i; } long cast_voidp_to_long (void const *i) { return (long)i; } void main(int argc, char* argv[]){ unsigned long a = 19; char b = a; return; } We had this error message: cannot cast from/to void It happened because the return type of the functions (`func_vt`) was not set properly by `riscv-gen.c` and it was VT_VOID by default. In the `mob` branch they moved all this code to `tccgen.c` to avoid repeating it in every single architecture, but that made me miss it during the backport of the RISC-V backend. This commit adds that piece of code but there might be more places where a similar thing happens.
This commit is contained in:
parent
aa727e57d2
commit
6fbd17852a
|
@ -928,8 +928,11 @@ ST_FUNC void gfunc_prolog(CType *func_type)
|
|||
addr = 0;
|
||||
/* if the function returns by reference, then add an
|
||||
implicit pointer parameter */
|
||||
func_vt = sym->type;
|
||||
func_var = (sym->c == FUNC_ELLIPSIS);
|
||||
size = type_size(&func_vt, &align);
|
||||
if (size > 2 * XLEN) {
|
||||
if (((func_vt.t & VT_BTYPE) == VT_STRUCT)
|
||||
&& (size > 2 * XLEN)) {
|
||||
loc -= 8;
|
||||
func_vc = loc;
|
||||
ES(0x23, 3, 8, 10 + areg[0]++, loc); // sd a0, loc(s0)
|
||||
|
|
Loading…
Reference in New Issue