diff --git a/tools/qfcc/test/Makemodule.am b/tools/qfcc/test/Makemodule.am index 1f310048a..88b9e8480 100644 --- a/tools/qfcc/test/Makemodule.am +++ b/tools/qfcc/test/Makemodule.am @@ -31,6 +31,7 @@ test_progs_dat=\ tools/qfcc/test/infloop.dat \ tools/qfcc/test/ivar-struct-return.dat \ tools/qfcc/test/link_order.dat \ + tools/qfcc/test/lost-use.dat \ tools/qfcc/test/methodparams.dat \ tools/qfcc/test/modulo.dat \ tools/qfcc/test/nilparamret.dat \ @@ -386,6 +387,16 @@ tools/qfcc/test/link_order.run: $(qfcc_test_run_deps) include $(link_order_dep) # am--include-marker r_depfiles_remade += $(link_order_dep) +tools_qfcc_test_lost_use_dat_SOURCES=tools/qfcc/test/lost-use.r +lost_use_obj=$(tools_qfcc_test_lost_use_dat_SOURCES:.r=.o) +lost_use_dep=$(call qcautodep,$(tools_qfcc_test_lost_use_dat_SOURCES)) +tools/qfcc/test/lost-use.dat$(EXEEXT): $(lost_use_obj) $(QFCC_DEP) + $(V_QFCCLD)$(QLINK) -o $@ $(lost_use_obj) +tools/qfcc/test/lost-use.run: $(qfcc_test_run_deps) + @$(top_srcdir)/tools/qfcc/test/build-run $@ +include $(lost_use_dep) # am--include-marker +r_depfiles_remade += $(lost_use_dep) + tools_qfcc_test_methodparams_dat_SOURCES=tools/qfcc/test/methodparams.r methodparams_obj=$(tools_qfcc_test_methodparams_dat_SOURCES:.r=.o) methodparams_dep=$(call qcautodep,$(tools_qfcc_test_methodparams_dat_SOURCES)) diff --git a/tools/qfcc/test/lost-use.r b/tools/qfcc/test/lost-use.r new file mode 100644 index 000000000..dc9d79142 --- /dev/null +++ b/tools/qfcc/test/lost-use.r @@ -0,0 +1,29 @@ +void printf (string fmt, ...) = #0; +int getval(void) +{ + return 42; +} + +void magic (void) +{ +} + +void storeval (int *p) +{ + int x = getval (); + magic (); + *p = x; +} + +int val; + +int +main(void) +{ + storeval (&val); + if (val != 42) { + printf ("val is dead: %d\n", val); + return 1; + } + return 0; +}