/[gcc]
ViewVC logotype

Revision 279755


Jump to revision: Previous Next
Author: mpolacek
Date: Sun Dec 29 16:44:41 2019 UTC (5 weeks, 1 day ago)
Changed paths: 21 (showing only 10; show all)
Log Message:
	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.


Changed paths

Path Details
Directorytrunk/gcc/cp/ChangeLog modified , text changed
Directorytrunk/gcc/cp/constexpr.c modified , text changed
Directorytrunk/gcc/cp/rtti.c modified , text changed
Directorytrunk/gcc/testsuite/ChangeLog modified , text changed
Directorytrunk/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic1.C added
Directorytrunk/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic10.C added
Directorytrunk/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic11.C added
Directorytrunk/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic12.C added
Directorytrunk/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic13.C added
Directorytrunk/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic14.C added
[...]

  ViewVC Help
Powered by ViewVC 1.1.26