The code I factored out of expand_or_defer_fn_1 into
tentative_decl_linkage is intended for use with functions that are
defined; using it on functions that have not been defined causes problems.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 2e63bb7138e59e7e04e2649fb3d8086fffc238a7
Author: Jason Merrill <ja...@redhat.com>
Date: Thu Feb 27 09:15:02 2014 -0500
PR c++/60353
PR c++/55877
* decl2.c (tentative_decl_linkage): Don't mess with functions that
are not yet defined.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 1afe16e..dfc532d 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2564,7 +2564,8 @@ tentative_decl_linkage (tree decl)
be handled. */;
else if (vague_linkage_p (decl))
{
- if (TREE_CODE (decl) == FUNCTION_DECL)
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && decl_defined_p (decl))
{
DECL_EXTERNAL (decl) = 1;
DECL_NOT_REALLY_EXTERN (decl) = 1;
@@ -2586,11 +2587,8 @@ tentative_decl_linkage (tree decl)
DECL_INTERFACE_KNOWN (decl) = 1;
}
}
- else
- {
- gcc_assert (TREE_CODE (decl) == VAR_DECL);
- maybe_commonize_var (decl);
- }
+ else if (TREE_CODE (decl) == VAR_DECL)
+ maybe_commonize_var (decl);
}
}
diff --git a/gcc/testsuite/g++.dg/other/anon6.C b/gcc/testsuite/g++.dg/other/anon6.C
new file mode 100644
index 0000000..2fd0942
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/anon6.C
@@ -0,0 +1,8 @@
+// PR c++/60353
+
+struct A {
+ A(int);
+};
+typedef struct {
+ A format;
+} B;