public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/49387 (strange error with typeid)
@ 2011-07-01  0:53 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2011-07-01  0:53 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 516 bytes --]

Here we were winding up in get_tinfo_decl with a template type that was 
still incomplete because nothing else had required it to be complete. 
So we initially decide to treat it as a class with no bases.  But then 
the process of creating the initializer for the type_info node causes 
the type to be complete, so we generate an initializer for a class with 
bases, which doesn't match the type we already gave it.

Fixed by instantiating the type in get_tinfo_decl.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 49387.patch --]
[-- Type: text/x-patch, Size: 1196 bytes --]

commit 9e18be69b4b6177e94597a20b43ff42f8e8f33bb
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 30 18:52:18 2011 -0400

    	PR c++/49387
    	* rtti.c (get_pseudo_ti_index): Call complete_type.

diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 0feaf07..53404b4 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -406,6 +406,8 @@ get_tinfo_decl (tree type)
     type = build_function_type (TREE_TYPE (type),
 				TREE_CHAIN (TYPE_ARG_TYPES (type)));
 
+  type = complete_type (type);
+
   /* For a class type, the variable is cached in the type node
      itself.  */
   if (CLASS_TYPE_P (type))
diff --git a/gcc/testsuite/g++.dg/rtti/template1.C b/gcc/testsuite/g++.dg/rtti/template1.C
new file mode 100644
index 0000000..e2a0376
--- /dev/null
+++ b/gcc/testsuite/g++.dg/rtti/template1.C
@@ -0,0 +1,23 @@
+// PR c++/49387
+
+#include <typeinfo>
+
+struct ResourceMonitorClient { };
+
+template <typename T> struct ResourcePool : public ResourceMonitorClient {
+  virtual ~ResourcePool() { }
+};
+
+template <typename T> struct BaseWriter {
+
+  BaseWriter() {
+    typeid(ResourcePool<int>*);
+  }
+
+  virtual void run() {
+    ResourcePool<int> pool;
+  }
+
+};
+
+BaseWriter<void> b;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-07-01  0:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-01  0:53 C++ PATCH for c++/49387 (strange error with typeid) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).