]> 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:28:39 +0000 (09:28 -0800)
commit1076ffda6ce5e6d5fc9577deaf8233e549e5787a
tree07b3e51ad2ff7d8c60a24afcce3e28eb4d4dd8f7
parent7d8585c0c0e5934780281abdee256ae6553e56e8
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>
gcc/gimple-ssa-warn-access.cc
gcc/testsuite/g++.dg/warn/Wmismatched-new-delete-8.C [new file with mode: 0644]