Since r13-3299, build_dynamic_cast_1 calls pushdecl which calls
duplicate_decls and that in this testcase emits the "conflicting
declaration" error and returns error_mark_node, so the subsequent
build_cxx_call crashes on the error_mark_node.
PR c++/115501
gcc/cp/ChangeLog:
* rtti.cc (build_dynamic_cast_1): Return if dcast_fn is erroneous.
gcc/testsuite/ChangeLog:
* g++.dg/rtti/dyncast8.C: New test.
pop_abi_namespace (flags);
dynamic_cast_node = dcast_fn;
}
+ if (dcast_fn == error_mark_node)
+ return error_mark_node;
result = build_cxx_call (dcast_fn, 4, elems, complain);
SET_EXPR_LOCATION (result, loc);
--- /dev/null
+// PR c++/115501
+// { dg-do compile }
+
+struct s{virtual void f();};
+struct s1 : s{};
+namespace __cxxabiv1
+{
+ extern "C" void __dynamic_cast(); // { dg-message "previous declaration" }
+}
+void diagnostic_information_impl(s const *se)
+{
+ dynamic_cast<s1 const *>(se);
+}
+
+// { dg-error "conflicting declaration" "" { target *-*-* } 0 }