aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-07-25 14:21:47 -0600
committerMartin Sebor <msebor@redhat.com>2020-07-25 14:24:24 -0600
commite0633768a1a2efe689e5505b3a95aa949d704b06 (patch)
treea9e31ce6ccb77f15b15ef50a3db7a32180034f14 /gcc/c-family
parent8d0b2b33748014ee57973c1d7bc9fd7706bb3da9 (diff)
downloadgcc-e0633768a1a2efe689e5505b3a95aa949d704b06.zip
gcc-e0633768a1a2efe689e5505b3a95aa949d704b06.tar.gz
gcc-e0633768a1a2efe689e5505b3a95aa949d704b06.tar.bz2
Fix PR c++/96310 - Ignoring -Wnonnull via pragma gcc diagnostics still produces an unwanted note.
gcc/c-family/ChangeLog: PR c++/96310 * c-common.c (check_nonnull_arg): Print note only when warning was issued.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-common.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 51ecde6..e2569c6 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5538,7 +5538,7 @@ check_nonnull_arg (void *ctx, tree param, unsigned HOST_WIDE_INT param_num)
{
warned = warning_at (loc, OPT_Wnonnull,
"%qs pointer null", "this");
- if (pctx->fndecl)
+ if (warned && pctx->fndecl)
inform (DECL_SOURCE_LOCATION (pctx->fndecl),
"in a call to non-static member function %qD",
pctx->fndecl);
@@ -5548,7 +5548,7 @@ check_nonnull_arg (void *ctx, tree param, unsigned HOST_WIDE_INT param_num)
warned = warning_at (loc, OPT_Wnonnull,
"argument %u null where non-null expected",
(unsigned) param_num);
- if (pctx->fndecl)
+ if (warned && pctx->fndecl)
inform (DECL_SOURCE_LOCATION (pctx->fndecl),
"in a call to function %qD declared %qs",
pctx->fndecl, "nonnull");