From ce17cff7f725fef6ed670ecf02ae92ee4dba79dc Mon Sep 17 00:00:00 2001 From: Yashas Date: Fri, 8 Jun 2018 21:17:11 +0530 Subject: [PATCH] trigger destructor not implemented error ``` #include forward operator~(Error:right[], size); main() { new Error:e; } ``` ``` CODE 0 ; 0 ;program exit point halt 0 proc ; main ; line 4 ; line 5 break ; c ;$lcl e fffffffc push.c 0 ;$exp push.pri push.c 1 addr.pri fffffffc push.pri push.c 8 call .~4000000f ; operator~(Error:) pop.pri stack 4 zero.pri retn STKSIZE 1000 ``` The compiler tries to call a non-existent function. This commit instead throws "function not implemented" error when destructor definition is missing. --- source/compiler/sc1.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 116a65e..655678b 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -4967,6 +4967,14 @@ static void destructsymbols(symbol *root,int level) /* check that the '~' operator is defined for this tag */ operator_symname(symbolname,"~",sym->tag,0,1,0); if ((opsym=findglb(symbolname,sGLOBAL))!=NULL) { + if ((opsym->usage & uMISSING)!=0 || (opsym->usage & uPROTOTYPED)==0) { + char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ + funcdisplayname(symname,opsym->name); + if ((opsym->usage & uMISSING)!=0) + error(4,symname); /* function not defined */ + if ((opsym->usage & uPROTOTYPED)==0) + error(71,symname); /* operator must be declared before use */ + } /* if */ /* save PRI, in case of a return statment */ if (!savepri) { pushreg(sPRI); /* right-hand operand is in PRI */