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?
commit 9febd1e3a2af987ecd1a62417b8948f679550254
Author: Jason Merrill <ja...@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);