mirror of
https://github.com/mirror/tinycc.git
synced 2025-03-30 12:20:06 +08:00
a void to void cast.
Allow tcc to compile the following program /////// void func1() {} void func2() { return func1(); } ////// gcc accepts this program
This commit is contained in:
parent
09feeca5df
commit
6fd4e5bace
14
tccgen.c
14
tccgen.c
@ -2412,8 +2412,20 @@ static void gen_assign_cast(CType *dt)
|
|||||||
st = &vtop->type; /* source type */
|
st = &vtop->type; /* source type */
|
||||||
dbt = dt->t & VT_BTYPE;
|
dbt = dt->t & VT_BTYPE;
|
||||||
sbt = st->t & VT_BTYPE;
|
sbt = st->t & VT_BTYPE;
|
||||||
if (sbt == VT_VOID || dbt == VT_VOID)
|
if (sbt == VT_VOID || dbt == VT_VOID) {
|
||||||
|
if (sbt == VT_VOID && dbt == VT_VOID)
|
||||||
|
; /*
|
||||||
|
It is Ok if both are void
|
||||||
|
A test program:
|
||||||
|
void func1() {}
|
||||||
|
void func2() {
|
||||||
|
return func1();
|
||||||
|
}
|
||||||
|
gcc accepts this program
|
||||||
|
*/
|
||||||
|
else
|
||||||
tcc_error("cannot cast from/to void");
|
tcc_error("cannot cast from/to void");
|
||||||
|
}
|
||||||
if (dt->t & VT_CONSTANT)
|
if (dt->t & VT_CONSTANT)
|
||||||
tcc_warning("assignment of read-only location");
|
tcc_warning("assignment of read-only location");
|
||||||
switch(dbt) {
|
switch(dbt) {
|
||||||
|
Loading…
Reference in New Issue
Block a user