]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
waccess: Fix handling of extended builtin types [PR123849]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 28 Jan 2026 00:55:45 +0000 (16:55 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 28 Jan 2026 08:32:11 +0000 (00:32 -0800)
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.

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 <andrew.pinski@oss.qualcomm.com>
gcc/gimple-ssa-warn-access.cc
gcc/testsuite/g++.dg/warn/Wmismatched-new-delete-11.C [new file with mode: 0644]

index df34da2bf9603e63803ca86d4c89ffa6bf76c0f0..c8f10cae32f54e811b4ef7035fd7a0e202a8ec65 100644 (file)
@@ -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 (file)
index 0000000..8191a81
--- /dev/null
@@ -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();
+}