This PR complains that we issue a -Wnonnull even in a decltype.
This fix disables even -Wformat and -Wrestrict. I think that's fine.
PR c++/115580
gcc/c-family/ChangeLog:
* c-common.cc (check_function_arguments): Return early if
c_inhibit_evaluation_warnings.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wnonnull16.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
{
bool warned_p = false;
+ if (c_inhibit_evaluation_warnings)
+ return warned_p;
+
/* Check for null being passed in a pointer argument that must be
non-null. In C++, this includes the this pointer. We also need
to do this if format checking is enabled. */
--- /dev/null
+// 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" }
+}