The FUNCTION_DECL we build for __dynamic_cast has an empty DECL_CONTEXT
but trees_out::tree_node expects FUNCTION_DECLs to have non-empty
DECL_CONTEXT, thus we crash when streaming out the dynamic_cast in the
below testcase.
This patch naively fixes this by setting DECL_CONTEXT for __dynamic_cast
appropriately. I suppose we should push it into the namespace too, like
we do for __cxa_atexit which is similarly lazily declared.
PR c++/106304
gcc/cp/ChangeLog:
* constexpr.cc (cxx_dynamic_cast_fn_p): Check for abi_node
instead of global_namespace.
* rtti.cc (build_dynamic_cast_1): Set DECL_CONTEXT and
DECL_SOURCE_LOCATION when building dynamic_cast_node. Push
it into the namespace.
gcc/testsuite/ChangeLog:
* g++.dg/modules/pr106304_a.C: New test.
* g++.dg/modules/pr106304_b.C: New test.