c++: Poor diagnostic for dynamic_cast in constexpr context [PR93414]
authorMarek Polacek <polacek@redhat.com>
Fri, 24 Jan 2020 23:08:58 +0000 (18:08 -0500)
committerMarek Polacek <polacek@redhat.com>
Sat, 25 Jan 2020 19:26:07 +0000 (14:26 -0500)
commitde0684bf3f72c1e7a29704bce215ab40bcb84bb6
tree0c6b84992dd87dd390731bee7c92d1c38438af14
parent10be08aa276916b4dc286abc269ed0a175f033dd
c++: Poor diagnostic for dynamic_cast in constexpr context [PR93414]

I neglected to add a proper diagnostic for the reference dynamic_cast
case when the operand of a dynamic_cast doesn't refer to a public base
of Derived, resulting in suboptimal error message

   error: call to non-'constexpr' function 'void* __cxa_bad_cast()'

2020-01-25  Marek Polacek  <polacek@redhat.com>

PR c++/93414 - poor diagnostic for dynamic_cast in constexpr context.
* constexpr.c (cxx_eval_dynamic_cast_fn): Add a reference
dynamic_cast diagnostic.

* g++.dg/cpp2a/constexpr-dynamic18.C: New test.
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic18.C [new file with mode: 0644]