]> git.ipfire.org Git - thirdparty/gcc.git/commit
warn-access: Fix handling of unnamed types [PR109804]
authorAndrew Pinski <quic_apinski@quicinc.com>
Thu, 22 Feb 2024 04:12:21 +0000 (20:12 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Thu, 22 Feb 2024 17:53:47 +0000 (09:53 -0800)
commita15427e75f2521ed5e467e3c5cb8446586bbdabb
tree5f026436c9dc2e53dc7f6067b5cad5bba09c087c
parent0e438772e788244236045d75cd2be895e2ab4e08
warn-access: Fix handling of unnamed types [PR109804]

This looks like an oversight of handling DEMANGLE_COMPONENT_UNNAMED_TYPE.
DEMANGLE_COMPONENT_UNNAMED_TYPE only has the u.s_number.number set while
the code expected newc.u.s_binary.left would be valid.
So this treats DEMANGLE_COMPONENT_UNNAMED_TYPE like we treat function paramaters
(DEMANGLE_COMPONENT_FUNCTION_PARAM) and template paramaters (DEMANGLE_COMPONENT_TEMPLATE_PARAM).

Note the code in the demangler does this when it sets DEMANGLE_COMPONENT_UNNAMED_TYPE:
      ret->type = DEMANGLE_COMPONENT_UNNAMED_TYPE;
      ret->u.s_number.number = num;

Committed as obvious after bootstrap/test on x86_64-linux-gnu

PR tree-optimization/109804

gcc/ChangeLog:

* gimple-ssa-warn-access.cc (new_delete_mismatch_p): Handle
DEMANGLE_COMPONENT_UNNAMED_TYPE.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wmismatched-new-delete-8.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 1076ffda6ce5e6d5fc9577deaf8233e549e5787a)
gcc/gimple-ssa-warn-access.cc
gcc/testsuite/g++.dg/warn/Wmismatched-new-delete-8.C [new file with mode: 0644]