[Bug other/94629] 10 issues located by the PVS-studio static analyzer
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Apr 17 10:31:25 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94629
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Comment on attachment 48299
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48299
sorted list of redundant assignments
/* If there were any declarations or structure tags in that level,
or if this level is a function body,
create a BLOCK to record them for the life of this function. */
block = NULL_TREE;
/* Avoid function body block if possible. */
if (functionbody && subblocks && BLOCK_CHAIN (subblocks) == NULL_TREE)
keep = 0;
else if (keep == 1 || functionbody)
block = make_node (BLOCK);
if (block != NULL_TREE)
{
BLOCK_VARS (block) = decls;
BLOCK_SUBBLOCKS (block) = subblocks;
}
/* In each subblock, record that this is its superior. */
if (keep >= 0)
for (link = subblocks; link; link = BLOCK_CHAIN (link))
BLOCK_SUPERCONTEXT (link) = block;
certainly doesn't look like redundant assignment, yes, the block = NULL_TREE
could be moved into the if, but that is just programming style.
I must say I don't understand why the separate if (block != NULL_TREE) is in
there, perhaps from historic reasons there might have been more cases.
Now it would make much more sense to just do
else if (keep == 1 || functionbody)
{
block = make_node (BLOCK);
BLOCK_VARS (block) = decls;
BLOCK_SUBBLOCKS (block) = subblocks;
}
More information about the Gcc-bugs
mailing list