This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][C++] Fix PR51262
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 9 Dec 2011 10:16:42 +0100 (CET)
- Subject: [PATCH][C++] Fix PR51262
The following fixes PR51262, the new type alias code does
else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
which ICEs when t is a type with an anonymous name with -flto
because we clear such TYPE_NAMEs during cp_free_lang_data.
It turns out that doing so is no longer necessary because we
now ignore names when merging canonical types (and thus C and
C++ interoperate just fine).
Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?
Thanks,
Richard.
2011-12-09 Richard Guenther <rguenther@suse.de>
PR lto/51262
* tree.c (cp_free_lang_data): No longer clear anonymous names.
* g++.dg/opt/pr51262.C: New testcase.
Index: gcc/cp/tree.c
===================================================================
--- gcc/cp/tree.c (revision 182117)
+++ gcc/cp/tree.c (working copy)
@@ -3479,17 +3479,6 @@ cp_free_lang_data (tree t)
DECL_EXTERNAL (t) = 1;
TREE_STATIC (t) = 0;
}
- if (CP_AGGREGATE_TYPE_P (t)
- && TYPE_NAME (t))
- {
- tree name = TYPE_NAME (t);
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
- /* Drop anonymous names. */
- if (name != NULL_TREE
- && ANON_AGGRNAME_P (name))
- TYPE_NAME (t) = NULL_TREE;
- }
if (TREE_CODE (t) == NAMESPACE_DECL)
{
/* The list of users of a namespace isn't useful for the middle-end
Index: gcc/testsuite/g++.dg/opt/pr51262.C
===================================================================
--- gcc/testsuite/g++.dg/opt/pr51262.C (revision 0)
+++ gcc/testsuite/g++.dg/opt/pr51262.C (revision 0)
@@ -0,0 +1,21 @@
+// { dg-do compile }
+// { dg-require-effective-target lto }
+// { dg-options "-flto -g" }
+
+template < typename > void *
+bar (int *p)
+{
+ union
+ {
+ int *p;
+ }
+ u;
+ u.p = p;
+ return u.p;
+}
+
+void
+foo (int *p)
+{
+ bar < void >(p);
+}