On 1/20/21 7:30 PM, Martin Sebor wrote:
Similar to pr96003, bug 98646 reports a spurious instance of -Wnonnull
calling a member function on the result of static_cast.  The difference
here is that the cast argument is a function call, and, besides casting
down an inheritance hierarchy, the cast also adds the const qualifier.
GCC sets the NO_WARNING bit for the COND_EXPR it emits for the cast
in these cases to avoid issuing spurious -Wnonnull warnings but then
doesn't preserve the bit in a call to cp_fold_convert() on it, leading
to the false positive.

The attached patch arranges for cp_fold_convert() to propagate the bit
to the result, preventing the front end -Wnonnull handler from issuing
the warning.

In addition, it also improves the wording of the message (suggested by
users in the past).

+  if (nowarn)
+    TREE_NO_WARNING (conv) = nowarn;

Let's only do this if the TREE_CODE of conv is the same as expr. OK with that change.

Jason

Reply via email to