re PR c++/42697 (ice-on-legal-code: template class template function local objects)
authorDodji Seketeli <dodji@redhat.com>
Sun, 17 Jan 2010 10:24:16 +0000 (10:24 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Sun, 17 Jan 2010 10:24:16 +0000 (11:24 +0100)
Fix PR c++/42697

gcc/cp/ChangeLog:
PR c++/42697
*pt.c (tsubst_decl): Get the arguments of a specialization from
the specialization template, not from the most general template.

gcc/testsuite/ChangeLog:
PR c++/42697
* g++.dg/template/crash94.C: New test.

From-SVN: r155975

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

index 08307272a00b786cfa302db9900885308956c49a..dc563cc2524ab0af3cd314616dbece9d72584ba3 100644 (file)
@@ -1,3 +1,9 @@
+2010-01-17  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/42697
+       *pt.c (tsubst_decl): Get the arguments of a specialization from
+       the specialization template, not from the most general template.
+
 2010-01-16  Jason Merrill  <jason@redhat.com>
 
        PR c++/42761
index f27b931edd824be5f9b4e3e98d90547c8d72f6eb..0acb86064198ac12599cd44c8ab5ed440d3c8aab 100644 (file)
@@ -8825,7 +8825,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
               specialize R.  */
            gen_tmpl = most_general_template (DECL_TI_TEMPLATE (t));
            argvec = tsubst_template_args (DECL_TI_ARGS
-                                          (DECL_TEMPLATE_RESULT (gen_tmpl)),
+                                          (DECL_TEMPLATE_RESULT
+                                                 (DECL_TI_TEMPLATE (t))),
                                           args, complain, in_decl);
 
            /* Check to see if we already have this specialization.  */
index 1302d42db3ae82349b9b9251f666df8ac796a53c..8211355516b3bde562800f0472747c9c67fb0206 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-17  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/42697
+       * g++.dg/template/crash94.C: New test.
+
 2010-01-17  Jie Zhang  <jie.zhang@analog.com>
 
        PR debug/42767
diff --git a/gcc/testsuite/g++.dg/template/crash94.C b/gcc/testsuite/g++.dg/template/crash94.C
new file mode 100644 (file)
index 0000000..810aed0
--- /dev/null
@@ -0,0 +1,28 @@
+// Origin: PR c++/42697
+// { dg-do compile }
+
+template<class Value_t>
+class fparser
+{
+    template<bool Option>
+    void eval2(Value_t r[2]);
+public:
+    void evaltest();
+};
+
+template<>
+template<bool Option>
+void fparser<int>::eval2(int r[2])
+{
+    struct ObjType {};
+}
+
+
+template<class Value_t>
+void fparser<Value_t>::evaltest
+    ()
+{
+    eval2<false>(0);
+}
+
+template class fparser<int>;