aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-10-22 14:37:53 -0400
committerJason Merrill <jason@gcc.gnu.org>2010-10-22 14:37:53 -0400
commit59dd34c40837ec0eadb3b08206c9d2cf558bc482 (patch)
tree133efb456de2bed3f891e614097334da3cbe10fb
parentf91352dcc350244cdfecca727b9daf2a652f0bea (diff)
downloadgcc-59dd34c40837ec0eadb3b08206c9d2cf558bc482.zip
gcc-59dd34c40837ec0eadb3b08206c9d2cf558bc482.tar.gz
gcc-59dd34c40837ec0eadb3b08206c9d2cf558bc482.tar.bz2
re PR c++/46129 (ICE: in tsubst_copy, at cp/pt.c:11375)
PR c++/46129 * pt.c (instantiate_class_template): Don't instantiate default arguments. From-SVN: r165850
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c17
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/defarg14.C13
4 files changed, 28 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7e4bdbf..6a3d5c7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2010-10-22 Jason Merrill <jason@redhat.com>
+ PR c++/46129
+ * pt.c (instantiate_class_template): Don't instantiate default
+ arguments.
+
PR c++/46103
* init.c (build_vec_init): Handle memberwise move.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 85a5ea5..19e8512 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8238,17 +8238,12 @@ instantiate_class_template (tree type)
finish_struct_1 (type);
TYPE_BEING_DEFINED (type) = 0;
- /* Now that the class is complete, instantiate default arguments for
- any member functions. We don't do this earlier because the
- default arguments may reference members of the class. */
- if (!PRIMARY_TEMPLATE_P (templ))
- for (t = TYPE_METHODS (type); t; t = DECL_CHAIN (t))
- if (TREE_CODE (t) == FUNCTION_DECL
- /* Implicitly generated member functions will not have template
- information; they are not instantiations, but instead are
- created "fresh" for each instantiation. */
- && DECL_TEMPLATE_INFO (t))
- tsubst_default_arguments (t);
+ /* We don't instantiate default arguments for member functions. 14.7.1:
+
+ The implicit instantiation of a class template specialization causes
+ the implicit instantiation of the declarations, but not of the
+ definitions or default arguments, of the class member functions,
+ member classes, static data members and member templates.... */
/* Some typedefs referenced from within the template code need to be access
checked at template instantiation time, i.e now. These types were
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b1bf64f..5c254e1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2010-10-22 Jason Merrill <jason@redhat.com>
+ PR c++/46129
+ * g++.dg/template/defarg14.C: New.
+
+2010-10-22 Jason Merrill <jason@redhat.com>
+
PR c++/46103
* g++.dg/cpp0x/implicit10.C: New.
diff --git a/gcc/testsuite/g++.dg/template/defarg14.C b/gcc/testsuite/g++.dg/template/defarg14.C
new file mode 100644
index 0000000..1fe87e3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/defarg14.C
@@ -0,0 +1,13 @@
+// PR c++/46129
+// The default argument for A<int>::B::operator() should not be instantiated
+
+template <class T>
+struct A {
+ struct B {
+ void operator () (const T& d_ = f(T()) ) { }
+ };
+};
+
+int main() {
+ A<int>::B b;
+}