diff --git a/tools/qfcc/test/Makemodule.am b/tools/qfcc/test/Makemodule.am index f5111177e..e6ada0a81 100644 --- a/tools/qfcc/test/Makemodule.am +++ b/tools/qfcc/test/Makemodule.am @@ -29,6 +29,7 @@ test_progs_dat=\ tools/qfcc/test/func-expr2.dat \ tools/qfcc/test/func-static.dat \ tools/qfcc/test/gcd.dat \ + tools/qfcc/test/ifsuper.dat \ tools/qfcc/test/infloop.dat \ tools/qfcc/test/iterfunc.dat \ tools/qfcc/test/ivar-struct-return.dat \ @@ -369,6 +370,16 @@ tools/qfcc/test/gcd.run: $(qfcc_test_run_deps) include $(gcd_dep) # am--include-marker pas_depfiles_remade += $(gcd_dep) +tools_qfcc_test_ifsuper_dat_SOURCES=tools/qfcc/test/ifsuper.r +ifsuper_obj=$(tools_qfcc_test_ifsuper_dat_SOURCES:.r=.o) +ifsuper_dep=$(call qcautodep,$(tools_qfcc_test_ifsuper_dat_SOURCES)) +tools/qfcc/test/ifsuper.dat$(EXEEXT): $(ifsuper_obj) $(QFCC_DEP) + $(V_QFCCLD)$(QLINK) --advanced -o $@ $(ifsuper_obj) +tools/qfcc/test/ifsuper.run: $(qfcc_test_run_deps) + @$(top_srcdir)/tools/qfcc/test/build-run $@ +include $(ifsuper_dep) # am--include-marker +r_depfiles_remade += $(ifsuper_dep) + tools_qfcc_test_infloop_dat_SOURCES=tools/qfcc/test/infloop.r infloop_obj=$(tools_qfcc_test_infloop_dat_SOURCES:.r=.o) infloop_dep=$(call qcautodep,$(tools_qfcc_test_infloop_dat_SOURCES)) diff --git a/tools/qfcc/test/ifsuper.r b/tools/qfcc/test/ifsuper.r new file mode 100644 index 000000000..58e916102 --- /dev/null +++ b/tools/qfcc/test/ifsuper.r @@ -0,0 +1,56 @@ +#pragma advanced +#include "test-harness.h" + +int obj_increment_retaincount (id object) = #0; +int obj_get_retaincount (id object) = #0; +id (Class class) class_create_instance = #0; +id obj_msgSend_super (Super *class, SEL op, ...) = #0; + +@interface Object +{ + Class isa; +} ++(id) alloc; +-(id) init; +@end + +@interface Foo : Object +-(id) init; +@end + +@implementation Object ++(id) alloc +{ + return class_create_instance (self); +} +-(id) init +{ + obj_increment_retaincount (self); + return self; +} +@end + +@implementation Foo +-(id) init +{ + if (!(self = [super init])) { + return nil; + } + return self; +} +@end + +int main () +{ + Foo *foo = [[Foo alloc] init]; + if (!foo) { + printf ("foo is nil\n"); + return 1; + } + int retain = obj_get_retaincount (foo); + if (retain != 1) { + printf ("retain count != 1: %d\n", retain); + return 1; + } + return 0; +} diff --git a/tools/qfcc/test/test-harness.h b/tools/qfcc/test/test-harness.h index 63f368416..51c5bde12 100644 --- a/tools/qfcc/test/test-harness.h +++ b/tools/qfcc/test/test-harness.h @@ -3,6 +3,8 @@ void printf (string fmt, ...) = #0; int errno (void) = #0; string strerror (int err) = #0; void exit (int code) = #0; +void traceon (void) = #0; +void traceoff (void) = #0; entity spawn (void) = #0; void remove (entity e) = #0; id obj_msgSend (id receiver, SEL op, ...) = #0;