On Wed, Jan 28, 2026 at 7:00 AM Andrew Pinski <[email protected]> wrote: > > So DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE is not being handled > from the demangler in new_delete_mismatch_p. This adds the handling, > just like DEMANGLE_COMPONENT_BUILTIN_TYPE as there is no simple way > to compare the type you have to call into the demanager to do it > instead. > > Bootstrapped and tested on x86_64-linux-gnu.
OK. > PR tree-optimization/123849 > > gcc/ChangeLog: > > * gimple-ssa-warn-access.cc (new_delete_mismatch_p): Handle > DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE like > DEMANGLE_COMPONENT_BUILTIN_TYPE. > > gcc/testsuite/ChangeLog: > > * g++.dg/warn/Wmismatched-new-delete-11.C: New test. > > Signed-off-by: Andrew Pinski <[email protected]> > --- > gcc/gimple-ssa-warn-access.cc | 1 + > .../g++.dg/warn/Wmismatched-new-delete-11.C | 45 +++++++++++++++++++ > 2 files changed, 46 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/warn/Wmismatched-new-delete-11.C > > diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc > index df34da2bf96..c8f10cae32f 100644 > --- a/gcc/gimple-ssa-warn-access.cc > +++ b/gcc/gimple-ssa-warn-access.cc > @@ -1701,6 +1701,7 @@ new_delete_mismatch_p (const demangle_component &newc, > return new_delete_mismatch_p (*newc.u.s_dtor.name, > *delc.u.s_dtor.name); > > + case DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE: > case DEMANGLE_COMPONENT_BUILTIN_TYPE: > { > /* The demangler API provides no better way to compare built-in > diff --git a/gcc/testsuite/g++.dg/warn/Wmismatched-new-delete-11.C > b/gcc/testsuite/g++.dg/warn/Wmismatched-new-delete-11.C > new file mode 100644 > index 00000000000..8191a812058 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/warn/Wmismatched-new-delete-11.C > @@ -0,0 +1,45 @@ > +// PR tree-optimization/123849 > +// { dg-do compile { target c++11 } } > +// { dg-options "-Wall" } > +// { dg-add-options float16 } > +// { dg-require-effective-target float16 } > + > +#include <new> > + > +template<typename Derived> class MatrixBase > +{ > +public: > + MatrixBase(); > +}; > + > +template<typename Derived> > +class PlainObjectBase : public MatrixBase<Derived> > +{ > +public: > + void *operator new(std::size_t size); > + void operator delete(void * ptr); > +}; > + > +template<typename _Scalar> > +class Matrix > + : public PlainObjectBase<Matrix<_Scalar> > > +{ > +}; > + > +template<typename T> > +struct resource > +{ > + T& makeref() const > + { > + T* ret = new T; > + return *ret; > + } > +}; > + > + > +using T = Matrix<_Float16>; > + > +void func(resource<T>& A) > +{ > + (void)A.makeref(); > +} > -- > 2.43.0 >
