From b0e98b16ec57a4ab300fe7174a7228dc276c9b5c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 17 Jul 2014 22:30:13 -0700 Subject: [PATCH] Mark usage correctly when invoking special natives. --- sourcepawn/compiler/sc1.c | 5 ++++- sourcepawn/compiler/sc4.c | 8 ++++++-- sourcepawn/compiler/tests/ok-reparse-delete.sp | 12 ++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 sourcepawn/compiler/tests/ok-reparse-delete.sp diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 0753737e..15f5f06c 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -4214,7 +4214,10 @@ static void dodelete() { pushval(1); ffcall(map->dtor->target, NULL, 1); - markusage(map->dtor->target, uREAD); + + // Only mark usage if we're not skipping codegen. + if (sc_status != statSKIP) + markusage(map->dtor->target, uREAD); } if (zap) { diff --git a/sourcepawn/compiler/sc4.c b/sourcepawn/compiler/sc4.c index fe0ba809..70c6f06f 100644 --- a/sourcepawn/compiler/sc4.c +++ b/sourcepawn/compiler/sc4.c @@ -1415,7 +1415,9 @@ SC_FUNC void invoke_getter(methodmap_method_t *method) pushreg(sPRI); pushval(1); ffcall(method->getter, NULL, 1); - markusage(method->getter, uREAD); + + if (sc_status != statSKIP) + markusage(method->getter, uREAD); } SC_FUNC void invoke_setter(methodmap_method_t *method, int save) @@ -1433,5 +1435,7 @@ SC_FUNC void invoke_setter(methodmap_method_t *method, int save) ffcall(method->setter, NULL, 2); if (save) popreg(sPRI); - markusage(method->setter, uREAD); + + if (sc_status != statSKIP) + markusage(method->setter, uREAD); } diff --git a/sourcepawn/compiler/tests/ok-reparse-delete.sp b/sourcepawn/compiler/tests/ok-reparse-delete.sp new file mode 100644 index 00000000..6886cdea --- /dev/null +++ b/sourcepawn/compiler/tests/ok-reparse-delete.sp @@ -0,0 +1,12 @@ +methodmap Handle { + public native ~Handle(); +} + +stock Crab(Handle h) +{ + delete h; +} + +public main() +{ +}