diff options
author | Martin Sebor <msebor@redhat.com> | 2020-07-31 10:27:33 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2020-07-31 10:27:33 -0600 |
commit | df5cf47a978aaeb53fc2b18ff0b22eb4531a27d8 (patch) | |
tree | 7a00548585cab2802e93e64d5924e4d2d178b52e /gcc/cp/class.c | |
parent | 4143efc1eed44050201b20c78d0206bc266e30c4 (diff) | |
download | gcc-df5cf47a978aaeb53fc2b18ff0b22eb4531a27d8.zip gcc-df5cf47a978aaeb53fc2b18ff0b22eb4531a27d8.tar.gz gcc-df5cf47a978aaeb53fc2b18ff0b22eb4531a27d8.tar.bz2 |
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.
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 7a25d8f..b39bdaa 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -516,8 +516,14 @@ build_base_path (enum tree_code code, out: if (null_test) - expr = fold_build3_loc (input_location, COND_EXPR, target_type, null_test, expr, - build_zero_cst (target_type)); + { + expr = fold_build3_loc (input_location, COND_EXPR, target_type, null_test, + expr, build_zero_cst (target_type)); + /* Avoid warning for the whole conditional expression (in addition + to NULL_TEST itself -- see above) in case the result is used in + a nonnull context that the front end -Wnonnull checks. */ + TREE_NO_WARNING (expr) = 1; + } return expr; } |