c++: avoid -Wdangling-reference for std::span-like classes [PR110358]
Real-world experience shows that -Wdangling-reference triggers for
user-defined std::span-like classes a lot. We can easily avoid that
by considering classes like
template<typename T>
struct Span {
T* data_;
std::size len_;
};
to be std::span-like, and not warning for them. Unlike the previous
patch, this one considers a non-union class template that has a pointer
data member and a trivial destructor as std::span-like.
PR c++/110358
PR c++/109640
gcc/cp/ChangeLog:
* call.cc (reference_like_class_p): Don't warn for std::span-like
classes.
gcc/ChangeLog:
* doc/invoke.texi: Update -Wdangling-reference description.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wdangling-reference18.C: New test.
* g++.dg/warn/Wdangling-reference19.C: New test.
* g++.dg/warn/Wdangling-reference20.C: New test.