mirror of
https://github.com/irmen/prog8.git
synced 2024-11-01 00:10:48 +00:00
take ignore_unused option into account for warnings about removing unused blocks themselves as well
This commit is contained in:
parent
b93fa75377
commit
ff23fb0086
@ -69,14 +69,14 @@ class UnusedCodeRemover(private val program: Program,
|
|||||||
override fun after(block: Block, parent: Node): Iterable<IAstModification> {
|
override fun after(block: Block, parent: Node): Iterable<IAstModification> {
|
||||||
if("force_output" !in block.options()) {
|
if("force_output" !in block.options()) {
|
||||||
if (block.containsNoCodeNorVars) {
|
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 })
|
if(!block.statements.any { it is Subroutine && it.hasBeenInlined })
|
||||||
errors.info("removing unused block '${block.name}'", block.position)
|
errors.info("removing unused block '${block.name}'", block.position)
|
||||||
}
|
}
|
||||||
return listOf(IAstModification.Remove(block, parent as IStatementContainer))
|
return listOf(IAstModification.Remove(block, parent as IStatementContainer))
|
||||||
}
|
}
|
||||||
if(callgraph.unused(block)) {
|
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 })
|
if(!block.statements.any { it is Subroutine && it.hasBeenInlined })
|
||||||
errors.info("removing unused block '${block.name}'", block.position)
|
errors.info("removing unused block '${block.name}'", block.position)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user