diff --git a/tools/qfcc/test/Makemodule.am b/tools/qfcc/test/Makemodule.am index 057382f75..d5929e0a6 100644 --- a/tools/qfcc/test/Makemodule.am +++ b/tools/qfcc/test/Makemodule.am @@ -30,6 +30,7 @@ test_progs_dat=\ tools/qfcc/test/gcd.dat \ tools/qfcc/test/infloop.dat \ tools/qfcc/test/ivar-struct-return.dat \ + tools/qfcc/test/link_order.dat \ tools/qfcc/test/methodparams.dat \ tools/qfcc/test/modulo.dat \ tools/qfcc/test/nilparamret.dat \ @@ -370,6 +371,16 @@ tools/qfcc/test/ivar-struct-return.run: $(qfcc_test_run_deps) include $(ivar_struct_return_dep) # am--include-marker r_depfiles_remade += $(ivar_struct_return_dep) +tools_qfcc_test_link_order_dat_SOURCES=tools/qfcc/test/link_order.r +link_order_obj=$(tools_qfcc_test_link_order_dat_SOURCES:.r=.o) +link_order_dep=$(call qcautodep,$(tools_qfcc_test_link_order_dat_SOURCES)) +tools/qfcc/test/link_order.dat$(EXEEXT): $(link_order_obj) $(QFCC_DEP) + $(V_QFCCLD)$(QLINK) -o $@ $(link_order_obj) +tools/qfcc/test/link_order.run: $(qfcc_test_run_deps) + @$(top_srcdir)/tools/qfcc/test/build-run $@ +include $(link_order_dep) # am--include-marker +r_depfiles_remade += $(link_order_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/link_order.r b/tools/qfcc/test/link_order.r new file mode 100644 index 000000000..9b0cdc73b --- /dev/null +++ b/tools/qfcc/test/link_order.r @@ -0,0 +1,44 @@ +#pragma bug die +#include "test-harness.h" + +typedef struct link_s { + int something; + struct link_s *next; +} link_t; + +link_t * +link_objs(link_t **array, int count) +{ + link_t *obj = nil, *o; + while (count-- > 0) { + o = array[count]; + o.next = obj; + obj = o; + } + return obj; +} + +link_t link_a; +link_t link_b; +link_t *links[2]; + +int +main () +{ + links[0] = &link_a; + links[1] = &link_b; + link_t *chain = link_objs (links, 2); + if (chain != &link_a) { + printf ("chain doesn't point to link_a\n"); + return 1; + } + if (chain.next != &link_b) { + printf ("chain.next doesn't point to link_b\n"); + return 1; + } + if (chain.next.next != nil) { + printf ("chain.next.next isn't nil\n"); + return 1; + } + return 0; +}