From df5cf47a978aaeb53fc2b18ff0b22eb4531a27d8 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Fri, 31 Jul 2020 10:27:33 -0600 Subject: Set and test no-warning bit to avoid -Wnonnull for synthesized expressions. Resolves: PR c++/96003 spurious -Wnonnull calling a member on the result of static_cast gcc/c-family/ChangeLog: PR c++/96003 * c-common.c (check_function_arguments_recurse): Return early when no-warning bit is set. gcc/cp/ChangeLog: PR c++/96003 * class.c (build_base_path): Set no-warning bit on the synthesized conditional expression in static_cast. gcc/testsuite/ChangeLog: PR c++/96003 * g++.dg/warn/Wnonnull7.C: New test. --- gcc/c-family/c-common.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/c-family/c-common.c') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index b97539c..96ed233 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5822,6 +5822,9 @@ check_function_arguments_recurse (void (*callback) void *ctx, tree param, unsigned HOST_WIDE_INT param_num) { + if (TREE_NO_WARNING (param)) + return; + if (CONVERT_EXPR_P (param) && (TYPE_PRECISION (TREE_TYPE (param)) == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (param, 0))))) -- cgit v1.1