]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* pt.c (instantiate_decl): Always instantiate static data members
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 28 Oct 2000 21:37:21 +0000 (21:37 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 28 Oct 2000 21:37:21 +0000 (21:37 +0000)
initialized in-class.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37107 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.other/instan1.C [new file with mode: 0644]

index 7cd501f954168ca3c725e3d03ff07035d55d3187..21d670c766347468ded1fd98398fd6cb41050f05 100644 (file)
@@ -1,3 +1,8 @@
+2000-10-28  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (instantiate_decl): Always instantiate static data members
+       initialized in-class.
+
 2000-10-27  Zack Weinberg  <zack@wolery.stanford.edu>
 
        * Make-lang.in: Move all build rules here from Makefile.in,
index f7e27ce5d020dd7319c3f083717dc255a3799c5d..8ca2468a0b28c4a9938e1fc6260d77d96cfbaa1e 100644 (file)
@@ -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 (file)
index 0000000..87c966d
--- /dev/null
@@ -0,0 +1,24 @@
+// Build don't run:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+// Special g++ Options: -fno-implicit-templates
+
+template <class T>
+struct U {
+  static int j;
+};
+
+template <class T>
+struct S {
+  static const int i = 7;
+};
+
+template <class T>
+const int S<T>::i;
+
+template <class T>
+int U<T>::j = S<T>::i + 5;
+
+template int U<double>::j;
+
+int main () {
+}