From 215ff61216dd3da1e84c0515c7314b4f6ac2199c Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 26 Nov 2012 21:05:24 +0900 Subject: [PATCH] Add a test for the dead boolean expression. This tests the zombie label problem found via ctf. --- tools/qfcc/test/Makefile.am | 9 ++++++++- tools/qfcc/test/deadbool.r | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tools/qfcc/test/deadbool.r diff --git a/tools/qfcc/test/Makefile.am b/tools/qfcc/test/Makefile.am index 736ed8942..54a264f9e 100644 --- a/tools/qfcc/test/Makefile.am +++ b/tools/qfcc/test/Makefile.am @@ -18,7 +18,7 @@ QFCC_TEST_LIBS=@QFCC_TEST_LIBS@ QFCC_TEST_DEPS=@QFCC_TEST_DEPS@ QFCC_TEST_INCS=@QFCC_TEST_INCS@ -test_progs_dat=infloop.dat modulo.dat structptr.dat while.dat +test_progs_dat=deadbool.dat infloop.dat modulo.dat structptr.dat while.dat TESTS=$(test_progs_dat:.dat=.run) @@ -28,6 +28,13 @@ test_harness_SOURCES= test-bi.c test-harness.c test_harness_LDADD= $(QFCC_TEST_LIBS) test_harness_DEPENDENCIES= $(QFCC_TEST_DEPS) +deadbool_dat_SOURCES=deadbool.r +deadbool_obj=$(deadbool_dat_SOURCES:.r=.qfo) +deadbool.dat: $(deadbool_obj) $(QFCC_DEP) + $(QFCC) $(QCFLAGS) -o $@ $(deadbool_obj) +deadbool.run: Makefile build-run + $(srcdir)/build-run $@ + infloop_dat_SOURCES=infloop.r infloop_obj=$(infloop_dat_SOURCES:.r=.qfo) infloop.dat: $(infloop_obj) $(QFCC_DEP) diff --git a/tools/qfcc/test/deadbool.r b/tools/qfcc/test/deadbool.r new file mode 100644 index 000000000..c4869b293 --- /dev/null +++ b/tools/qfcc/test/deadbool.r @@ -0,0 +1,19 @@ +entity spawn (void) { return nil; } +.float f; +float time; + +void foo (void) +{ + local entity ent; + + return; + if (!time) { + ent = spawn (); + ent.f = time + 0.1; + } +} + +int main () +{ + return 0; // if the test compiles, it passes. +}