diff options
author | Marek Polacek <polacek@redhat.com> | 2019-12-29 16:44:41 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2019-12-29 16:44:41 +0000 |
commit | 22edf9431e4519c409ebf41c7589cccfb8c4b625 (patch) | |
tree | c4cb09adb7774b0c2c01d580d49c46ea9d4a394e /gcc/fortran/iresolve.c | |
parent | 6ec067548fa994158819db0a62a8b5356d452c2c (diff) | |
download | gcc-22edf9431e4519c409ebf41c7589cccfb8c4b625.zip gcc-22edf9431e4519c409ebf41c7589cccfb8c4b625.tar.gz gcc-22edf9431e4519c409ebf41c7589cccfb8c4b625.tar.bz2 |
PR c++/88337 - Implement P1327R1: Allow dynamic_cast in constexpr.
This patch implements
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1327r1.html>.
When build_dynamic_cast realizes that a dynamic_cast needs a run-time check, it
generates a call to __dynamic_cast -- see dyncast.cc in libsupc++ for its
definition. The gist of my approach is to evaluate such a call at compile time.
* constexpr.c (cxx_dynamic_cast_fn_p): New function.
(extract_obj_from_addr_offset): New function.
(get_component_with_type): New function.
(cxx_eval_dynamic_cast_fn): New function.
(cxx_eval_call_expression): Call cxx_eval_dynamic_cast_fn for a call
to __dynamic_cast.
(potential_constant_expression_1): Don't give up on
cxx_dynamic_cast_fn_p.
* rtti.c (build_dynamic_cast_1): When creating a call to
__dynamic_cast, use the location of the original expression.
* g++.dg/cpp2a/constexpr-dynamic1.C: New test.
* g++.dg/cpp2a/constexpr-dynamic10.C: New test.
* g++.dg/cpp2a/constexpr-dynamic11.C: New test.
* g++.dg/cpp2a/constexpr-dynamic12.C: New test.
* g++.dg/cpp2a/constexpr-dynamic13.C: New test.
* g++.dg/cpp2a/constexpr-dynamic14.C: New test.
* g++.dg/cpp2a/constexpr-dynamic15.C: New test.
* g++.dg/cpp2a/constexpr-dynamic16.C: New test.
* g++.dg/cpp2a/constexpr-dynamic17.C: New test.
* g++.dg/cpp2a/constexpr-dynamic2.C: New test.
* g++.dg/cpp2a/constexpr-dynamic3.C: New test.
* g++.dg/cpp2a/constexpr-dynamic4.C: New test.
* g++.dg/cpp2a/constexpr-dynamic5.C: New test.
* g++.dg/cpp2a/constexpr-dynamic6.C: New test.
* g++.dg/cpp2a/constexpr-dynamic7.C: New test.
* g++.dg/cpp2a/constexpr-dynamic8.C: New test.
* g++.dg/cpp2a/constexpr-dynamic9.C: New test.
From-SVN: r279755
Diffstat (limited to 'gcc/fortran/iresolve.c')
0 files changed, 0 insertions, 0 deletions