aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-02-24 14:50:30 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-02-24 14:50:30 +0000
commitccfbd8805b8207ae6377e362f59e774144c8f367 (patch)
tree7e1b1c01b30c4eed53ee4993e2a3550c5494a08b /gcc
parent844216f3811e342886523f1ee4a3068afb4dc726 (diff)
downloadgcc-ccfbd8805b8207ae6377e362f59e774144c8f367.zip
gcc-ccfbd8805b8207ae6377e362f59e774144c8f367.tar.gz
gcc-ccfbd8805b8207ae6377e362f59e774144c8f367.tar.bz2
re PR c++/39242 (Inconsistent reject / accept of code)
2009-02-24 Richard Guenther <rguenther@suse.de> PR c++/39242 * pt.c (instantiate_decl): Do not instantiate extern, non-inline declared functions. * g++.dg/template/instantiate10.C: New testcase. From-SVN: r144408
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/instantiate10.C37
4 files changed, 55 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0af1372..139abc6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-24 Richard Guenther <rguenther@suse.de>
+
+ PR c++/39242
+ * pt.c (instantiate_decl): Do not instantiate extern, non-inline
+ declared functions.
+
2009-02-23 H.J. Lu <hongjiu.lu@intel.com>
PR c++/36411
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index bef6002..dacc868 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15295,9 +15295,14 @@ instantiate_decl (tree d, int defer_ok,
/* In general, we do not instantiate such templates... */
if (external_p
/* ... but we instantiate inline functions so that we can inline
- them and ... */
+ them. An explicit instantiation declaration prohibits implicit
+ instantiation of non-inline functions. With high levels of
+ optimization, we would normally inline non-inline functions
+ -- but we're not allowed to do that for "extern template" functions.
+ Therefore, we check DECL_DECLARED_INLINE_P, rather than
+ possibly_inlined_p. And ... */
&& ! (TREE_CODE (d) == FUNCTION_DECL
- && possibly_inlined_p (d))
+ && DECL_DECLARED_INLINE_P (d))
/* ... we instantiate static data members whose values are
needed in integral constant expressions. */
&& ! (TREE_CODE (d) == VAR_DECL
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4af6e18..00a2ce9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,4 +1,9 @@
2009-02-24 Richard Guenther <rguenther@suse.de>
+
+ PR c++/39242
+ * g++.dg/template/instantiate10.C: New testcase.
+
+2009-02-24 Richard Guenther <rguenther@suse.de>
Zdenek Dvorak <ook@ucw.cz>
PR tree-optimization/39233
diff --git a/gcc/testsuite/g++.dg/template/instantiate10.C b/gcc/testsuite/g++.dg/template/instantiate10.C
new file mode 100644
index 0000000..678e019
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/instantiate10.C
@@ -0,0 +1,37 @@
+/* PR c++/39242, xplicit instantiation declaration prohibits implicit
+ instantiation of non-inline functions. */
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+class Rep {
+public:
+ void unref() const { }
+ static void unref (const Rep * obj_r) { obj_r->unref(); }
+};
+template<typename _Tp, typename _Bt = _Tp>
+class RepPtrStore {
+ _Tp * _obj;
+ void _assign( _Tp * new_r );
+public:
+ ~RepPtrStore() { _assign( 0 ); }
+};
+template<typename _Tp,typename _Bt>
+void RepPtrStore<_Tp,_Bt>::_assign( _Tp * new_r )
+{
+ Rep::unref( _obj );
+}
+class RepPtrBase { };
+template<typename _Bt> class PtrBase : public RepPtrBase { };
+template<typename _Tp, typename _Bt = _Tp>
+class Ptr : public PtrBase<_Bt> {
+ RepPtrStore<_Tp,_Bt> _ptr;
+};
+class YCode;
+class YStatement;
+typedef Ptr<YStatement,YCode> YStatementPtr;
+extern template class RepPtrStore<YStatement,YCode>;
+class ExecutionEnvironment {
+ YStatementPtr m_statement;
+ ~ExecutionEnvironment() { };
+};
+