]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/32674 (ICE in lvalue_p_1 initialising static variable inside template class)
authorPaolo Carlini <pcarlini@suse.de>
Thu, 6 Sep 2007 19:19:15 +0000 (19:19 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 6 Sep 2007 19:19:15 +0000 (19:19 +0000)
/cp
2007-09-06  Paolo Carlini  <pcarlini@suse.de>

PR c++/32674
* decl.c (cp_finish_decl): When processing_template_decl,
deal correctly with init as TREE_LIST.

/testsuite
2007-09-06  Paolo Carlini  <pcarlini@suse.de>

PR c++/32674
* g++.dg/template/static31.C: New.

From-SVN: r128205

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

index 25806cee78d7997e6801a2ef6630d7281f5fb3dd..8cea1221e73392458b962d05d6a0e7b2c8f8f6b1 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-06  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/32674
+       * decl.c (cp_finish_decl): When processing_template_decl,
+       deal correctly with init as TREE_LIST.
+
 2007-09-05  Paolo Carlini  <pcarlini@suse.de>
 
        PR c++/33210
index 3fee2763fc560d57338e1431ecf1e6d8a4d434ac..5b5858df7cd53e1c3afa63034e86a5d4f2d0a2b2 100644 (file)
@@ -5214,7 +5214,21 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
          goto finish_end;
        }
 
-      init = fold_non_dependent_expr (init);
+      if (TREE_CODE (init) == TREE_LIST)
+       {
+         /* If the parenthesized-initializer form was used (e.g.,
+            "int A<N>::i(X)"), then INIT will be a TREE_LIST of initializer
+            arguments.  (There is generally only one.)  We convert them
+            individually.  */
+         tree list = init;
+         for (; list; list = TREE_CHAIN (list))
+           {
+             tree elt = TREE_VALUE (list);
+             TREE_VALUE (list) = fold_non_dependent_expr (elt);
+           }
+       }
+      else
+       init = fold_non_dependent_expr (init);
       processing_template_decl = 0;
     }
 
index 22977f9fb210644d990b65f1ff8f414c1167fef1..2643d8407f842919b063a2af376625d5447e7ccb 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-06  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/32674
+       * g++.dg/template/static31.C: New.
+
 2007-09-06  David Daney  <ddaney@avtrex.com>
            Richard Sandiford  <richard@codesourcery.com>
 
diff --git a/gcc/testsuite/g++.dg/template/static31.C b/gcc/testsuite/g++.dg/template/static31.C
new file mode 100644 (file)
index 0000000..935a8a7
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/32674
+
+class C
+{
+  static const int j = 3;
+};
+
+template<int> class A
+{
+  static const int i1;
+  static const int i2;
+  static const int i3;
+  static const int i4;
+};
+
+template<int N> const int A<N>::i1(C::j);
+template<int N> const int A<N>::i2 = C::j;
+template<int N> const int A<N>::i3(C::j, 5); // { dg-error "compound expression" }
+template<int N> const int A<N>::i4 = (C::j, 7);