From ef4f994e8bbf2cca77622682ba25c3bcb83ec79a Mon Sep 17 00:00:00 2001 From: belliash Date: Tue, 16 Apr 2019 12:34:53 +0200 Subject: [PATCH] Do not allow 'break' statement to take a parameter. This is strange construction introduced in PHP. --- engine/compiler.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/engine/compiler.c b/engine/compiler.c index b09b38c..1ff935f 100644 --- a/engine/compiler.c +++ b/engine/compiler.c @@ -1485,25 +1485,13 @@ static sxi32 PH7_CompileContinue(ph7_gen_state *pGen) { */ static sxi32 PH7_CompileBreak(ph7_gen_state *pGen) { GenBlock *pLoop; /* Target loop */ - sxi32 iLevel; /* How many nesting loop to skip */ sxu32 nLine; sxi32 rc; nLine = pGen->pIn->nLine; - iLevel = 0; /* Jump the 'break' keyword */ pGen->pIn++; - if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_NUM)) { - /* optional numeric argument which tells us how many levels - * of enclosing loops we should skip to the end of. - */ - iLevel = (sxi32)PH7_TokenValueToInt64(&pGen->pIn->sData); - if(iLevel < 2) { - iLevel = 0; - } - pGen->pIn++; /* Jump the optional numeric argument */ - } /* Extract the target loop */ - pLoop = PH7_GenStateFetchBlock(pGen->pCurrent, GEN_BLOCK_LOOP, iLevel); + pLoop = PH7_GenStateFetchBlock(pGen->pCurrent, GEN_BLOCK_LOOP, 0); if(pLoop == 0) { /* Illegal break */ rc = PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "A 'break' statement may only be used within a loop or switch"); @@ -1521,7 +1509,7 @@ static sxi32 PH7_CompileBreak(ph7_gen_state *pGen) { } if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_SEMI) == 0) { /* Not so fatal,emit a warning only */ - PH7_GenCompileError(&(*pGen), E_WARNING, pGen->pIn->nLine, "Expected semi-colon ';' after 'break' statement"); + PH7_GenCompileError(&(*pGen), E_ERROR, pGen->pIn->nLine, "Expected semi-colon ';' after 'break' statement"); } /* Statement successfully compiled */ return SXRET_OK;