This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] c++/37256: Fix 4.4 regression wrt external implicit instantiation

SVN revision 138150 introduced the "possibly_inlined_p" predicate.
However, when optimization is enabled, this predicate will return
true even for external entities such as external implicit template
instantiation, causing "mark_used" to emit "instantiate_decl".

This patch tells prevents "possibly_inlined_p" from returning true
for declarations tagged as really being external.

Note that I'm not familiar with this part of the code, so the fix
may be wrong.

Bootstrapped and tested on x86_64-pc-linux-gnu. Ok for trunk?

	PR c++/37256
	* decl2.c (possibly_inlined_p): Do not consider external
	declarations as being possibly inline.

	PR c++/37256
	* g++.dg/opt/pr37256.C: New test.
 gcc/cp/decl2.c                     |    2 +-
 gcc/testsuite/g++.dg/opt/pr37256.C |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/opt/pr37256.C

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b326752..e3ffadb 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3740,7 +3740,7 @@ bool
 possibly_inlined_p (tree decl)
   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
-  if (DECL_UNINLINABLE (decl))
     return false;
   if (!optimize)
     return DECL_DECLARED_INLINE_P (decl);
diff --git a/gcc/testsuite/g++.dg/opt/pr37256.C b/gcc/testsuite/g++.dg/opt/pr37256.C
new file mode 100644
index 0000000..7a199f2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr37256.C
@@ -0,0 +1,16 @@
+// Test for bug reported in pr37256
+// { dg-options "-O1" }
+// { dg-do "compile" }
+template <typename T_>
+struct B
+    T_ f();
+extern template class B<int>;
+void f()
+    B<int> t;
+    t.f();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]