re PR c++/23896 (boost::tie() = std::pair doesn't compile)
authorMark Mitchell <mark@codesourcery.com>
Fri, 16 Sep 2005 01:50:26 +0000 (01:50 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 16 Sep 2005 01:50:26 +0000 (01:50 +0000)
PR c++/23896
* pt.c (tsubst_aggr_type): Make sure skip_evaluation is false when
processing template arguments.

PR c++/23896
* g++.dg/template/static17.C: New test.

From-SVN: r104336

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

index 868ef3a4f663787cf8e8b450a4a806bdf5b46e69..188189f549012fe1c62cb7df19d2e8653f65d6de 100644 (file)
@@ -1,5 +1,9 @@
 2005-09-15  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/23896
+       * pt.c (tsubst_aggr_type): Make sure skip_evaluation is false when
+       processing template arguments.
+
        * pt.c (check_explicit_instantiation_namespace): Fix typo.
 
        PR c++/13140
index 8840d27f24b858979311d8ab7ae0ea6399a9739b..ece96146c2e7cae99e3c83e83c73033d403040ea 100644 (file)
@@ -6069,6 +6069,11 @@ tsubst_aggr_type (tree t,
          tree argvec;
          tree context;
          tree r;
+         bool saved_skip_evaluation;
+
+         /* In "sizeof(X<I>)" we need to evaluate "I".  */
+         saved_skip_evaluation = skip_evaluation;
+         skip_evaluation = false;
 
          /* First, determine the context for the type we are looking
             up.  */
@@ -6089,12 +6094,17 @@ tsubst_aggr_type (tree t,
          argvec = tsubst_template_args (TYPE_TI_ARGS (t), args,
                                         complain, in_decl);
          if (argvec == error_mark_node)
-           return error_mark_node;
-
-         r = lookup_template_class (t, argvec, in_decl, context,
-                                    entering_scope, complain);
+           r = error_mark_node;
+         else
+           {
+             r = lookup_template_class (t, argvec, in_decl, context,
+                                        entering_scope, complain);
+             r = cp_build_qualified_type_real (r, TYPE_QUALS (t), complain);
+           }
+         
+         skip_evaluation = saved_skip_evaluation;
 
-         return cp_build_qualified_type_real (r, TYPE_QUALS (t), complain);
+         return r;
        }
       else
        /* This is not a template type, so there's nothing to do.  */
index 39fc06a81d7818cfea30a79a9273aba72330dabc..e9b96a9869889fee7baacc2313d2f62fd8f01442 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-15  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/23896
+       * g++.dg/template/static17.C: New test.
+
 2005-09-15  Joseph S. Myers  <joseph@codesourcery.com>
 
        PR c++/23139
diff --git a/gcc/testsuite/g++.dg/template/static17.C b/gcc/testsuite/g++.dg/template/static17.C
new file mode 100644 (file)
index 0000000..bf79bcc
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/23896
+
+template <int> struct X {}; 
+template <typename T> struct length { 
+  static const int value = 2; 
+}; 
+template <typename T> void foo () { 
+  sizeof(X<length<T>::value>); 
+} 
+template void foo<int>();