diff mbox

RFA: tree.c PATCH for c++/51992 (TARGET_EXPR in LTO stream)

Message ID 4F202E06.2080202@redhat.com
State New
Headers show

Commit Message

Jason Merrill Jan. 25, 2012, 4:29 p.m. UTC
The problem here turns out to be that when free_lang_data_in_cgraph 
tries to find all the decls and types in a function, it doesn't catch a 
type that only appears in the fntype of a GIMPLE_CALL.  This patch fixes 
the bug; is there a better way to handle it?

Tested x86_64-pc-linux-gnu, OK for trunk?

Comments

Jakub Jelinek Jan. 25, 2012, 4:35 p.m. UTC | #1
On Wed, Jan 25, 2012 at 11:29:58AM -0500, Jason Merrill wrote:
> The problem here turns out to be that when free_lang_data_in_cgraph
> tries to find all the decls and types in a function, it doesn't
> catch a type that only appears in the fntype of a GIMPLE_CALL.  This
> patch fixes the bug; is there a better way to handle it?

Well, fntype isn't a gimple_op, so the generic code below it doesn't handle
it.  So I think it is fine.

> Tested x86_64-pc-linux-gnu, OK for trunk?

Yes.

> commit 9febd1e3a2af987ecd1a62417b8948f679550254
> Author: Jason Merrill <jason@redhat.com>
> Date:   Wed Jan 25 11:14:30 2012 -0500
> 
>     	PR c++/51992
>     	* tree.c (find_decls_types_in_node): Walk gimple_call_fntype.

	Jakub
Richard Biener Jan. 26, 2012, 9:27 a.m. UTC | #2
On Wed, 25 Jan 2012, Jason Merrill wrote:

> The problem here turns out to be that when free_lang_data_in_cgraph tries to
> find all the decls and types in a function, it doesn't catch a type that only
> appears in the fntype of a GIMPLE_CALL.  This patch fixes the bug; is there a
> better way to handle it?

No, that looks exactly right.
 
> Tested x86_64-pc-linux-gnu, OK for trunk?

Ok.

Thanks,
Richard.
diff mbox

Patch

commit 9febd1e3a2af987ecd1a62417b8948f679550254
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 25 11:14:30 2012 -0500

    	PR c++/51992
    	* tree.c (find_decls_types_in_node): Walk gimple_call_fntype.

diff --git a/gcc/testsuite/g++.dg/lto/pr51992_0.C b/gcc/testsuite/g++.dg/lto/pr51992_0.C
new file mode 100644
index 0000000..d178f9b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr51992_0.C
@@ -0,0 +1,53 @@ 
+// PR c++/51992
+// { dg-lto-do assemble }
+
+template<typename Enum>
+class QFlags
+{
+    int i;
+    inline QFlags(Enum f) : i(f) {}
+};
+class QString {};
+class KComponentData;
+class KConfig 
+{
+public:
+    enum OpenFlag {
+        IncludeGlobals = 0x01,
+	CascadeConfig = 0x02,
+	FullConfig = IncludeGlobals|CascadeConfig
+    };
+    typedef QFlags<OpenFlag> OpenFlags;
+};
+template <class T>
+class KSharedPtr {};
+class KSharedConfig : public KConfig
+{
+public:
+  typedef KSharedPtr<KSharedConfig> Ptr;
+    static KSharedConfig::Ptr openConfig(const QString& fileName = QString(),
+				         OpenFlags mode = FullConfig,
+					 const char *resourceType = "config");
+    static KSharedConfig::Ptr openConfig(const KComponentData &componentData,
+				         const QString &fileName = QString(),
+                                         OpenFlags mode = FullConfig,
+					 const char *resourceType = "config");
+};
+typedef KSharedConfig::Ptr KSharedConfigPtr;
+namespace KGlobal
+{
+    KComponentData &mainComponent();
+};
+KSharedConfigPtr KSharedConfig::openConfig(const QString& fileName,
+                                           OpenFlags flags,
+                                           const char *resType)
+{
+    return openConfig(KGlobal::mainComponent(), fileName, flags, resType);
+}
+KSharedConfigPtr KSharedConfig::openConfig(const KComponentData &componentData,
+                                           const QString& fileName,
+                                           OpenFlags flags,
+                                           const char *resType)
+{
+    return KSharedConfigPtr();
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index ec78616..34bcb39 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5037,6 +5037,9 @@  find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld)
 	{
 	  gimple stmt = gsi_stmt (si);
 
+	  if (is_gimple_call (stmt))
+	    find_decls_types (gimple_call_fntype (stmt), fld);
+
 	  for (i = 0; i < gimple_num_ops (stmt); i++)
 	    {
 	      tree arg = gimple_op (stmt, i);