PR c++/47326
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Feb 2011 20:45:15 +0000 (20:45 +0000)
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Feb 2011 20:45:15 +0000 (20:45 +0000)
gcc/cp/

PR c++/47326
* pt.c (tsubst_copy)<case SIZEOF_EXPR>: Ensure that even pack
expansion arguments are not evaluated.

gcc/testsuite/

PR c++/47326
* g++.dg/cpp0x/variadic106.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170222 138bc75d-0d04-0410-961f-82ee72b054a4

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

index d2972eb..dca9612 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-16  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/47326
+       * pt.c (tsubst_copy)<case SIZEOF_EXPR>: Ensure that even pack
+       expansion arguments are not evaluated.
+
 2011-02-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/47704
index fe3e954..aa956c8 100644 (file)
@@ -11382,11 +11382,18 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
     case SIZEOF_EXPR:
       if (PACK_EXPANSION_P (TREE_OPERAND (t, 0)))
         {
-          /* We only want to compute the number of arguments.  */
-          tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args,
-                                                complain, in_decl);
+
+          tree expanded;
          int len = 0;
 
+         ++cp_unevaluated_operand;
+         ++c_inhibit_evaluation_warnings;
+         /* We only want to compute the number of arguments.  */
+         expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args,
+                                           complain, in_decl);
+         --cp_unevaluated_operand;
+         --c_inhibit_evaluation_warnings;
+
          if (TREE_CODE (expanded) == TREE_VEC)
            len = TREE_VEC_LENGTH (expanded);
 
index a25d496..e11bdf3 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-16  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/47326
+       * g++.dg/cpp0x/variadic106.C: New test.
+
 2011-02-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR libfortran/47757
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic106.C b/gcc/testsuite/g++.dg/cpp0x/variadic106.C
new file mode 100644 (file)
index 0000000..80ec084
--- /dev/null
@@ -0,0 +1,22 @@
+// Origin: PR c++/47326
+// { dg-options  "-std=c++0x" }
+// { dg-do compile }
+
+template <int _N>
+struct A
+{
+  typedef int value_type;
+};
+
+template <typename... _ARGS>
+auto
+f (_ARGS... args) -> typename A<sizeof...(args)>::value_type
+{
+  return 12;
+}
+
+int
+main()
+{
+  f(1,2);
+}