From 930cd7963b4a8e30901950a1103c7a84257ee8db Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sat, 28 Oct 2000 21:37:21 +0000 Subject: [PATCH] pt.c (instantiate_decl): Always instantiate static data members initialized in-class. * pt.c (instantiate_decl): Always instantiate static data members initialized in-class. From-SVN: r37107 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/pt.c | 11 ++++----- .../g++.old-deja/g++.other/instan1.C | 24 +++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/instan1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7cd501f9541..21d670c7663 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-10-28 Mark Mitchell + + * pt.c (instantiate_decl): Always instantiate static data members + initialized in-class. + 2000-10-27 Zack Weinberg * Make-lang.in: Move all build rules here from Makefile.in, diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f7e27ce5d02..8ca2468a0b2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9614,12 +9614,6 @@ instantiate_decl (d, defer_ok) import_export_decl (d); } - /* Reject all external templates except inline functions. */ - if (DECL_INTERFACE_KNOWN (d) - && ! DECL_NOT_REALLY_EXTERN (d) - && ! (TREE_CODE (d) == FUNCTION_DECL && DECL_INLINE (d))) - goto out; - /* We need to set up DECL_INITIAL regardless of pattern_defined if the variable is a static const initialized in the class body. */ if (TREE_CODE (d) == VAR_DECL @@ -9627,6 +9621,11 @@ instantiate_decl (d, defer_ok) && DECL_INITIAL (d) == NULL_TREE && DECL_INITIAL (code_pattern) != NULL_TREE) ; + /* Reject all external templates except inline functions. */ + else if (DECL_INTERFACE_KNOWN (d) + && ! DECL_NOT_REALLY_EXTERN (d) + && ! (TREE_CODE (d) == FUNCTION_DECL && DECL_INLINE (d))) + goto out; /* Defer all other templates, unless we have been explicitly forbidden from doing so. We restore the source position here because it's used by add_pending_template. */ diff --git a/gcc/testsuite/g++.old-deja/g++.other/instan1.C b/gcc/testsuite/g++.old-deja/g++.other/instan1.C new file mode 100644 index 00000000000..87c966d1cd0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/instan1.C @@ -0,0 +1,24 @@ +// Build don't run: +// Origin: Mark Mitchell +// Special g++ Options: -fno-implicit-templates + +template +struct U { + static int j; +}; + +template +struct S { + static const int i = 7; +}; + +template +const int S::i; + +template +int U::j = S::i + 5; + +template int U::j; + +int main () { +}