From 616abc647c1fa14fabdbe708c4adcf88135916ef Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 3 Jun 2014 07:56:58 -0400 Subject: re PR c++/61020 (typeid(typeid(X)) produces 'ud2') PR c++/61020 * varpool.c (ctor_for_folding): Handle uninitialized vtables. From-SVN: r211178 --- gcc/varpool.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc/varpool.c') diff --git a/gcc/varpool.c b/gcc/varpool.c index 1697bb4..143cd3b 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -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. */ -- cgit v1.1