Skip to content

Commit

Permalink
Fix -Wnonnull warnings with GCC 11
Browse files Browse the repository at this point in the history
Version 11 and later of GCC consider the implicit `this` parameter of
nonstatic member functions to be annotated with `nonnull` for the
purposes of the `-Wnonnull` warning. This change generates new warnings
that are resolved here with the use of `TR_ASSERT_FATAL` on the objects
that the compiler thinks could be `NULL`. The macro `TR_ASSERT` is
insufficient, as the `TR::assertion` method isn't (and cannot be)
annotated with `OMR_NORETURN`.

Signed-off-by: Christian Despres <despresc@ibm.com>
  • Loading branch information
cjjdespres committed Sep 16, 2024
1 parent 8c233cd commit c40a511
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/infra/InterferenceGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ bool TR_InterferenceGraph::simplify()
}
}

TR_ASSERT(bestSpillNode, "Could not find a spill candidate.\n");
TR_ASSERT_FATAL(bestSpillNode, "Could not find a spill candidate");

virtualRemoveNodeFromIG(bestSpillNode);
workingSet->reset(bestSpillNode->getIndex());
Expand Down
2 changes: 1 addition & 1 deletion compiler/optimizer/CopyPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ void TR_CopyPropagation::replaceCopySymbolReferenceByOriginalIn(TR::SymbolRefere
if (origNode->getNumChildren() == 2)
{
twoChildrenCase = true;
TR_ASSERT(0, "Only in WCode we can add extra children\n");
TR_ASSERT_FATAL(false, "Cannot add extra children");
}
else
{
Expand Down
1 change: 1 addition & 0 deletions compiler/optimizer/Structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,7 @@ bool TR_RegionStructure::changeContinueLoopsToNestedLoops(TR_RegionStructure *ro
{
diagnostic("Incoming [%p] edge %d->%d\n", incomingEdge, incomingEdge->getFrom()->asBlock()->getNumber(), incomingEdge->getTo()->asBlock()->getNumber());
diagnostic("\tassuming it should be ->%d\n", entryBlock->getNumber());
TR_ASSERT_FATAL(newHeader, "New header must have been set by now");
diagnostic("\tredirecting to ->%d\n", newHeader->getNumber());
}

Expand Down

0 comments on commit c40a511

Please sign in to comment.