mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-26 03:50:07 +08:00
tccgen: gen_cast(): detect 'cast from void' error
This commit is contained in:
parent
72f1dea537
commit
97800177c9
14
tccgen.c
14
tccgen.c
@ -3695,6 +3695,12 @@ again:
|
|||||||
df = is_float(dbt);
|
df = is_float(dbt);
|
||||||
dbt_bt = dbt & VT_BTYPE;
|
dbt_bt = dbt & VT_BTYPE;
|
||||||
sbt_bt = sbt & VT_BTYPE;
|
sbt_bt = sbt & VT_BTYPE;
|
||||||
|
if (dbt_bt == VT_VOID)
|
||||||
|
goto done;
|
||||||
|
if (sbt_bt == VT_VOID) {
|
||||||
|
error:
|
||||||
|
cast_error(&vtop->type, type);
|
||||||
|
}
|
||||||
|
|
||||||
c = (vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
|
c = (vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
|
||||||
#if !defined TCC_IS_NATIVE && !defined TCC_IS_NATIVE_387
|
#if !defined TCC_IS_NATIVE && !defined TCC_IS_NATIVE_387
|
||||||
@ -3791,11 +3797,9 @@ again:
|
|||||||
|
|
||||||
ds = btype_size(dbt_bt);
|
ds = btype_size(dbt_bt);
|
||||||
ss = btype_size(sbt_bt);
|
ss = btype_size(sbt_bt);
|
||||||
if (ds == 0 || ss == 0) {
|
if (ds == 0 || ss == 0)
|
||||||
if (dbt_bt == VT_VOID)
|
goto error;
|
||||||
goto done;
|
|
||||||
cast_error(&vtop->type, type);
|
|
||||||
}
|
|
||||||
if (IS_ENUM(type->t) && type->ref->c < 0)
|
if (IS_ENUM(type->t) && type->ref->c < 0)
|
||||||
tcc_error("cast to incomplete type");
|
tcc_error("cast to incomplete type");
|
||||||
|
|
||||||
|
@ -394,4 +394,9 @@ struct S2 {
|
|||||||
#elif defined test_conflicting_array_definition
|
#elif defined test_conflicting_array_definition
|
||||||
extern int array[2];
|
extern int array[2];
|
||||||
int array[] = { 1, 2, 3 };
|
int array[] = { 1, 2, 3 };
|
||||||
|
|
||||||
|
#elif defined test_cast_from_void
|
||||||
|
void v() {}
|
||||||
|
int f() { return v(); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -186,3 +186,6 @@ bar : 3 ; 3
|
|||||||
|
|
||||||
[test_conflicting_array_definition]
|
[test_conflicting_array_definition]
|
||||||
60_errors_and_warnings.c:396: error: incompatible types for redefinition of 'array'
|
60_errors_and_warnings.c:396: error: incompatible types for redefinition of 'array'
|
||||||
|
|
||||||
|
[test_cast_from_void]
|
||||||
|
60_errors_and_warnings.c:400: error: cannot convert 'void' to 'int'
|
||||||
|
Loading…
Reference in New Issue
Block a user