PR c++/24277
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Oct 2005 06:26:04 +0000 (06:26 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Oct 2005 06:26:04 +0000 (06:26 +0000)
* pt.c (instantiate_decl): Call finish_static_data_member_decl for
static data members.
PR c++/24277
* g++.dg/template/static20.C: New test.

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

gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/static20.C [new file with mode: 0644]

index 2bd96a6..a5a7c1e 100644 (file)
@@ -11558,13 +11558,19 @@ instantiate_decl (tree d, int defer_ok,
          && !DECL_INITIAL (d) 
          && DECL_INITIAL (code_pattern))
        {
-         tree ns = decl_namespace_context (d);
+         tree ns;
+         tree init;
+
+         ns = decl_namespace_context (d);
          push_nested_namespace (ns);
          push_nested_class (DECL_CONTEXT (d));
-         DECL_INITIAL (d)
-           = tsubst_expr (DECL_INITIAL (code_pattern), 
-                          args,
-                          tf_error | tf_warning, NULL_TREE);
+         init = tsubst_expr (DECL_INITIAL (code_pattern), 
+                             args,
+                             tf_error | tf_warning, NULL_TREE);
+         DECL_INITIAL (d) = NULL_TREE;
+         finish_static_data_member_decl (d, init, 
+                                         /*asmspec_tree=*/NULL_TREE,
+                                         LOOKUP_ONLYCONVERTING);
          pop_nested_class ();
          pop_nested_namespace (ns);
        }
index aa4a66f..dd19af6 100644 (file)
@@ -1,5 +1,8 @@
 2005-10-10  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/24277
+       * g++.dg/template/static20.C: New test.
+
        PR c++/24302
        * g++.dg/warn/Wunused-12.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/static20.C b/gcc/testsuite/g++.dg/template/static20.C
new file mode 100644 (file)
index 0000000..6f1096b
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/24277
+
+template< int Bits > struct uint_t {
+  typedef unsigned short fast;
+};
+template < int Bits > struct mask_uint_t {
+  typedef typename uint_t< Bits >::fast fast;
+  static const fast sig_bits = 1;
+  static const fast sig_bits_fast = fast(sig_bits);
+};
+template < int Bits> int checksum ( ) {
+  return 1 & mask_uint_t<Bits>::sig_bits_fast;
+}
+int i = checksum<1>();