On 6/5/20 3:41 PM, Martin Sebor wrote:
+ location_t loc
+ = EXPR_HAS_LOCATION (param) ? EXPR_LOCATION (param) : pctx->loc;
This could be EXPR_LOC_OR_LOC (param, pctx->loc)
+ location_t loc = (EXPR_HAS_LOCATION (ptr)
+ ? EXPR_LOCATION (ptr) : EXPR_LOCATION (exp));
And similarly here.
+ if (param_num == 0)
{
+ warned = warning_at (loc, OPT_Wnonnull,
+ "%qs pointer null", "this");
+ if (pctx->fndecl)
+ inform (DECL_SOURCE_LOCATION (pctx->fndecl),
+ "in a call to non-static member function %qD",
+ pctx->fndecl);
}
+ else
+ {
+ warned = warning_at (loc, OPT_Wnonnull,
+ "argument %u null where non-null expected",
+ (unsigned) param_num);
+ if (pctx->fndecl)
+ inform (DECL_SOURCE_LOCATION (pctx->fndecl),
+ "in a call to function %qD declared %qs",
+ pctx->fndecl, "nonnull");
+ }
You need auto_diagnostic_group somewhere.
The c-common.c and tree.c changes are OK with these adjustments. I'll
leave the optimizer bits to someone else.
Jason