This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ RFC / patch] PR 32674
... so I tested the below on x86_64-linux.
Ok for mainline and 4_2-branch?
Paolo.
///////////////
/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.
Index: testsuite/g++.dg/template/static31.C
===================================================================
*** testsuite/g++.dg/template/static31.C (revision 0)
--- testsuite/g++.dg/template/static31.C (revision 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);
Index: cp/decl.c
===================================================================
*** cp/decl.c (revision 128180)
--- cp/decl.c (working copy)
*************** cp_finish_decl (tree decl, tree init, bo
*** 5333,5339 ****
goto finish_end;
}
! init = fold_non_dependent_expr (init);
processing_template_decl = 0;
}
--- 5333,5349 ----
goto finish_end;
}
! if (TREE_CODE (init) == TREE_LIST)
! {
! 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;
}