aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>2005-10-10 14:42:14 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-10-10 14:42:14 +0000
commit27a725e2935ad18edd9a92a2555f543d72af391d (patch)
tree71a75c334ad104b81d807cee2f2e9f8da74252dd /gcc
parentf0d60e22101308e3ed63e42ec33257742cc07380 (diff)
downloadgcc-27a725e2935ad18edd9a92a2555f543d72af391d.zip
gcc-27a725e2935ad18edd9a92a2555f543d72af391d.tar.gz
gcc-27a725e2935ad18edd9a92a2555f543d72af391d.tar.bz2
re PR c++/24275 (Previously accepted code fails with 4.0.2)
PR c++/24275 * pt.c (instantiate_decl): Instantiate the initializer of a static data member in the namespace containing the class containing the static data member. PR c++/24275 * g++.dg/template/static19.C: New test. From-SVN: r105173
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.c3
-rw-r--r--gcc/testsuite/g++.dg/template/static19.C18
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 317d17f..2bd96a6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11558,12 +11558,15 @@ instantiate_decl (tree d, int defer_ok,
&& !DECL_INITIAL (d)
&& DECL_INITIAL (code_pattern))
{
+ tree 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);
pop_nested_class ();
+ pop_nested_namespace (ns);
}
/* We restore the source position here because it's used by
diff --git a/gcc/testsuite/g++.dg/template/static19.C b/gcc/testsuite/g++.dg/template/static19.C
new file mode 100644
index 0000000..d720127
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/static19.C
@@ -0,0 +1,18 @@
+// PR c++/24275
+
+template <bool val> struct bool_var {
+ static const bool value = val;
+};
+namespace is_inc_ {
+ struct any {
+ template <class T> any(T const&);
+ };
+ int operator++(any const&);
+ template <class T> struct impl {
+ static T &x;
+ static const bool value = sizeof(++x) == 1;
+ };
+}
+template<typename T> struct is_incr : bool_var< is_inc_::impl<T>::value> {};
+struct not_incr{};
+typedef int sa1[ is_incr<not_incr>::value ? -1 : 1];