Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? -- >8 -- This PR complains that we issue a -Wnonnull even in a decltype. Since we can't use cp_unevaluated_operand in c-common.cc, this fix targets even -Wformat and -Wrestrict. I think that's fine.
PR c++/115580 gcc/cp/ChangeLog: * call.cc (build_over_call): Don't call check_function_arguments when cp_unevaluated_operand. gcc/testsuite/ChangeLog: * g++.dg/warn/Wnonnull16.C: New test. --- gcc/cp/call.cc | 1 + gcc/testsuite/g++.dg/warn/Wnonnull16.C | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/g++.dg/warn/Wnonnull16.C diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index be9b0cf62f1..87ca02507cf 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -10669,6 +10669,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) bool warned_p = false; if ((complain & tf_warning) + && !cp_unevaluated_operand && (warn_nonnull || warn_format || warn_suggest_attribute_format diff --git a/gcc/testsuite/g++.dg/warn/Wnonnull16.C b/gcc/testsuite/g++.dg/warn/Wnonnull16.C new file mode 100644 index 00000000000..8740f351ac7 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wnonnull16.C @@ -0,0 +1,16 @@ +// PR c++/115580 +// { dg-do compile { target c++11 } } + +class WithMember { +public: + int foo(); +}; + +decltype(((WithMember*)nullptr)->foo()) footype; // { dg-bogus "pointer is null" } + +int f(void*) __attribute__((nonnull)); + +void g() +{ + [[maybe_unused]] decltype(f(nullptr)) b; // { dg-bogus "non-null" } +} base-commit: 879fd9c822633ecf2c62471d1a7f9b9619e296b7 -- 2.48.1