]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/54844 (ice tsubst_copy, at cp/pt.c:12352)
authorJakub Jelinek <jakub@redhat.com>
Tue, 23 Oct 2012 18:04:55 +0000 (20:04 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 23 Oct 2012 18:04:55 +0000 (20:04 +0200)
PR c++/54844
* pt.c (tsubst_copy, tsubst_copy_and_build) <case SIZEOF_EXPR>: Use
tsubst instead of tsubst_copy* on types.

* g++.dg/template/sizeof14.C: New test.

From-SVN: r192736

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

index bb06612e15494637af138c337bb241a2afad7afd..1cad7963182f4901ac7d61fc5bab6302786d3cff 100644 (file)
@@ -1,5 +1,9 @@
 2012-10-23  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/54844
+       * pt.c (tsubst_copy, tsubst_copy_and_build) <case SIZEOF_EXPR>: Use
+       tsubst instead of tsubst_copy* on types.
+
        PR c++/54988
        * decl2.c (cplus_decl_attributes): Don't return early
        if attributes is NULL.
index 7e8d8b0880d75ca4c0e9fd01d51f0ca7b36cdb00..1ff1c73b90d7e9943856db88fde5d85106a3c4d8 100644 (file)
@@ -12104,8 +12104,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
         }
       if (SIZEOF_EXPR_TYPE_P (t))
        {
-         r = tsubst_copy (TREE_TYPE (TREE_OPERAND (t, 0)),
-                          args, complain, in_decl);
+         r = tsubst (TREE_TYPE (TREE_OPERAND (t, 0)),
+                     args, complain, in_decl);
          r = build1 (NOP_EXPR, r, error_mark_node);
          r = build1 (SIZEOF_EXPR,
                      tsubst (TREE_TYPE (t), args, complain, in_decl), r);
@@ -13533,10 +13533,13 @@ tsubst_copy_and_build (tree t,
          {
            ++cp_unevaluated_operand;
            ++c_inhibit_evaluation_warnings;
-           op1 = tsubst_copy_and_build (op1, args, complain, in_decl,
-                                        /*function_p=*/false,
-                                        /*integral_constant_expression_p=*/
-                                        false);
+           if (TYPE_P (op1))
+             op1 = tsubst (op1, args, complain, in_decl);
+           else
+             op1 = tsubst_copy_and_build (op1, args, complain, in_decl,
+                                          /*function_p=*/false,
+                                          /*integral_constant_expression_p=*/
+                                          false);
            --cp_unevaluated_operand;
            --c_inhibit_evaluation_warnings;
          }
index 0779858f6ea293f84f00a618cafc6531adbd2810..8267df660e07f0bd06fa54d39dd5ce90b6800dc2 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/54844
+       * g++.dg/template/sizeof14.C: New test.
+
 2012-10-23  Ian Bolton  <ian.bolton@arm.com>
            Jim MacArthur  <jim.macarthur@arm.com>
            Chris Schlumberger-Socha <chris.schlumberger-socha@arm.com>
diff --git a/gcc/testsuite/g++.dg/template/sizeof14.C b/gcc/testsuite/g++.dg/template/sizeof14.C
new file mode 100644 (file)
index 0000000..8f40204
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/54844
+// { dg-do compile }
+template <int N> int fn () { return sizeof (double); }
+int var = fn <0> ();