Don't use the expr type for assignments.

Instead, the type is taken from the source operand (this means the computed
type of .return for that var). ctf now builds :)
This commit is contained in:
Bill Currie 2012-11-30 20:47:36 +09:00
parent df66669a87
commit 5e9d7d3567
3 changed files with 31 additions and 1 deletions

View File

@ -675,7 +675,10 @@ dag_gencode (dag_t *dag, sblock_t *block, dagnode_t *dagnode)
internal_error (0, "non-leaf label in leaf node");
dst = dagnode->label->op;
if ((var_iter = set_first (dagnode->identifiers))) {
type = low_level_type (get_type (dagnode->label->expr));
type = dst->type;
if (dst->op_type == op_symbol
&& !strcmp (dst->o.symbol->name, ".return"))
type = dag->flownode->return_type.in;
dst = generate_assignments (dag, block, dst, var_iter, type);
}
break;

View File

@ -20,6 +20,7 @@ QFCC_TEST_INCS=@QFCC_TEST_INCS@
test_progs_dat=\
chewed-alias.dat \
chewed-return.dat \
deadbool.dat \
infloop.dat \
modulo.dat \
@ -41,6 +42,13 @@ chewed-alias.dat: $(chewed_alias_obj) $(QFCC_DEP)
chewed-alias.run: Makefile build-run
$(srcdir)/build-run $@
chewed_return_dat_SOURCES=chewed-return.r
chewed_return_obj=$(chewed_return_dat_SOURCES:.r=.qfo)
chewed-return.dat: $(chewed_return_obj) $(QFCC_DEP)
$(QFCC) $(QCFLAGS) -o $@ $(chewed_return_obj)
chewed-return.run: Makefile build-run
TEST_HARNESS_OPTS=--float $(srcdir)/build-run $@
deadbool_dat_SOURCES=deadbool.r
deadbool_obj=$(deadbool_dat_SOURCES:.r=.qfo)
deadbool.dat: $(deadbool_obj) $(QFCC_DEP)

View File

@ -0,0 +1,19 @@
#pragma traditional
entity spawn (void) {return @nil;}
float time;
.void () think;
.float nextthink;
void rthink(){}
void foo (void)
{
entity rspawn;
rspawn = spawn();
rspawn.nextthink = time + 0.1;
rspawn.think = rthink;
};
float main ()
{
return 0; // compile test
}