re PR c++/61020 (typeid(typeid(X)) produces 'ud2')
PR c++/61020 * varpool.c (ctor_for_folding): Handle uninitialized vtables. From-SVN: r211178
This commit is contained in:
parent
b31e65bb60
commit
616abc647c
3 changed files with 42 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2014-06-02 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/61020
|
||||
* varpool.c (ctor_for_folding): Handle uninitialized vtables.
|
||||
|
||||
2014-06-03 Alan Lawrence <alan.lawrence@arm.com>
|
||||
|
||||
* config/aarch64/aarch64.c (aarch64_evpc_ext): allow and handle
|
||||
|
|
27
gcc/testsuite/g++.dg/opt/typeinfo1.C
Normal file
27
gcc/testsuite/g++.dg/opt/typeinfo1.C
Normal file
|
@ -0,0 +1,27 @@
|
|||
// PR c++/61020
|
||||
// { dg-options "-O2" }
|
||||
// { dg-do run }
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
struct Base {
|
||||
virtual ~Base() { }
|
||||
};
|
||||
|
||||
struct Derived : public Base {
|
||||
};
|
||||
|
||||
int compare(const Base& base)
|
||||
{
|
||||
return typeid(base) == typeid(typeid(Derived));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Base base;
|
||||
Derived derived;
|
||||
|
||||
if (compare(base)) return 1;
|
||||
if (compare(derived)) return 2;
|
||||
return 0;
|
||||
}
|
|
@ -306,7 +306,16 @@ ctor_for_folding (tree decl)
|
|||
if (DECL_VIRTUAL_P (real_decl))
|
||||
{
|
||||
gcc_checking_assert (TREE_READONLY (real_decl));
|
||||
return DECL_INITIAL (real_decl);
|
||||
if (DECL_INITIAL (real_decl))
|
||||
return DECL_INITIAL (real_decl);
|
||||
else
|
||||
{
|
||||
/* The C++ front end creates VAR_DECLs for vtables of typeinfo
|
||||
classes not defined in the current TU so that it can refer
|
||||
to them from typeinfo objects. Avoid returning NULL_TREE. */
|
||||
gcc_checking_assert (!COMPLETE_TYPE_P (DECL_CONTEXT (real_decl)));
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
|
||||
/* If there is no constructor, we have nothing to do. */
|
||||
|
|
Loading…
Add table
Reference in a new issue