]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix unchecked use of CLASSTYPE_AS_BASE [PR113031]
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 15 Dec 2023 23:59:03 +0000 (10:59 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sat, 16 Dec 2023 04:09:50 +0000 (15:09 +1100)
commit39f9c426f58448d6df340cdccd84e05721a20921
treeef54f6899319cba903a142e3fb98febc27600782
parent0cfde688e2133844a5d9b6cce9f2e73b620ba072
c++: Fix unchecked use of CLASSTYPE_AS_BASE [PR113031]

My previous commit (naively) assumed that a TREE_CODE of RECORD_TYPE or
UNION_TYPE was sufficient for optype to be considered a "class type".
However, this does not account for e.g. template type parameters of
record or union type. This patch corrects to check for CLASS_TYPE_P
before checking for as-base conversion.

PR c++/113031

gcc/cp/ChangeLog:

* constexpr.cc (cxx_fold_indirect_ref_1): Check for CLASS_TYPE
before using CLASSTYPE_AS_BASE.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/pr113031.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/cpp0x/pr113031.C [new file with mode: 0644]