get emitted. */
for (i = unemitted_tinfo_decls->length ();
unemitted_tinfo_decls->iterate (--i, &t);)
- if (emit_tinfo_decl (t))
+ if (DECL_INITIAL (t) || emit_tinfo_decl (t))
{
reconsider = true;
unemitted_tinfo_decls->unordered_remove (i);
/* Emit it right away if not emitted already. */
if (DECL_INITIAL (tinfo) == NULL_TREE)
{
- gcc_assert (unemitted_tinfo_decls->last () == tinfo);
bool ok = emit_tinfo_decl (tinfo);
gcc_assert (ok);
- unemitted_tinfo_decls->pop ();
+ /* When compiling libsupc++.a (fundamental_type_info.o),
+ unemitted_tinfo_decls->last () will be tinfo, so pop it
+ from the vector as it is emitted now. If one uses typeid
+ etc. in the same TU as the definition of
+ ~fundamental_type_info (), the tinfo might be emitted
+ already earlier, in such case keep it in the vector
+ (as otherwise we'd need to walk the whole vector) and
+ let c_parse_final_cleanups ignore it when it will have
+ non-NULL DECL_INITIAL. */
+ if (unemitted_tinfo_decls->last () == tinfo)
+ unemitted_tinfo_decls->pop ();
}
}
}
--- /dev/null
+// PR c++/109042
+// { dg-do compile }
+
+namespace std { class type_info {}; }
+
+std::type_info
+foo ()
+{
+ return typeid (void);
+}
+
+namespace __cxxabiv1 {
+ struct __fundamental_type_info {
+ virtual ~__fundamental_type_info ();
+ };
+
+ __fundamental_type_info::~__fundamental_type_info ()
+ {
+ }
+}