From ff23fb00861e29e0c7d6d04ad7bbeabcf146ec5d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 29 Mar 2024 00:16:18 +0100 Subject: [PATCH] take ignore_unused option into account for warnings about removing unused blocks themselves as well --- codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt b/codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt index 839f9b18b..65499482f 100644 --- a/codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt +++ b/codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt @@ -69,14 +69,14 @@ class UnusedCodeRemover(private val program: Program, override fun after(block: Block, parent: Node): Iterable { if("force_output" !in block.options()) { if (block.containsNoCodeNorVars) { - if(block.name != internedStringsModuleName) { + if(block.name != internedStringsModuleName && "ignore_unused" !in block.options()) { if(!block.statements.any { it is Subroutine && it.hasBeenInlined }) errors.info("removing unused block '${block.name}'", block.position) } return listOf(IAstModification.Remove(block, parent as IStatementContainer)) } if(callgraph.unused(block)) { - if(block.statements.any{ it !is VarDecl || it.type== VarDeclType.VAR}) { + if(block.statements.any{ it !is VarDecl || it.type== VarDeclType.VAR} && "ignore_unused" !in block.options()) { if(!block.statements.any { it is Subroutine && it.hasBeenInlined }) errors.info("removing unused block '${block.name}'", block.position) }