PR c++/88337 - P1327R1: Allow polymorphic typeid in constexpr.
authorMarek Polacek <polacek@redhat.com>
Fri, 22 Nov 2019 23:48:25 +0000 (23:48 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 22 Nov 2019 23:48:25 +0000 (23:48 +0000)
commit66acfb8004d65ae8c75c627b511984f7f054a2ca
treefbb1081d2d91c1f058d8bd2e05325b0119def46d
parentbdaf8be1b2e3514b8bbcdd1042136e7d91b3c3f3
PR c++/88337 - P1327R1: Allow polymorphic typeid in constexpr.

Part of P1327R1 is to allow typeid with an operand of polymorphic type in
constexpr.  I found that we pretty much support it already, the only tweak
was to allow TYPEID_EXPR (only created in a template) in constexpr in C++20.

* constexpr.c (potential_constant_expression_1): Allow a typeid
expression whose operand is of polymorphic type in constexpr in
C++20.
* rtti.c (build_typeid): Remove obsolete FIXME comment.

* g++.dg/cpp2a/constexpr-typeid1.C: New test.
* g++.dg/cpp2a/constexpr-typeid2.C: New test.
* g++.dg/cpp2a/constexpr-typeid3.C: New test.
* g++.dg/cpp2a/constexpr-typeid4.C: New test.

From-SVN: r278635
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/rtti.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/constexpr-typeid1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-typeid2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-typeid3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-typeid4.C [new file with mode: 0644]