OSDN Git Service

PR c++/52043
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 31 Jan 2012 17:41:24 +0000 (17:41 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 31 Jan 2012 17:41:24 +0000 (17:41 +0000)
* cp-tree.h (PACK_EXPANSION_LOCAL_P): New.
* pt.c (make_pack_expansion, tsubst_initializer_list): Set it.
(tsubst_pack_expansion): Check it.

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

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

index 5c02259..8938ee2 100644 (file)
@@ -1,3 +1,10 @@
+2012-01-31  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52043
+       * cp-tree.h (PACK_EXPANSION_LOCAL_P): New.
+       * pt.c (make_pack_expansion, tsubst_initializer_list): Set it.
+       (tsubst_pack_expansion): Check it.
+
 2012-01-29  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/51327
index f27755e..d435dbd 100644 (file)
@@ -76,6 +76,7 @@ c-common.h, not after.
       TRANSACTION_EXPR_IS_STMT (in TRANSACTION_EXPR)
       CONVERT_EXPR_VBASE_PATH (in CONVERT_EXPR)
       OVL_ARG_DEPENDENT (in OVERLOAD)
+      PACK_EXPANSION_LOCAL_P (in *_PACK_EXPANSION)
    1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE)
       TI_PENDING_TEMPLATE_FLAG.
       TEMPLATE_PARMS_FOR_INLINE.
@@ -2839,6 +2840,9 @@ extern void decl_shadowed_for_var_insert (tree, tree);
     ? &TYPE_MAXVAL (NODE)                      \
     : &TREE_OPERAND ((NODE), 2))
 
+/* True iff this pack expansion is within a function context.  */
+#define PACK_EXPANSION_LOCAL_P(NODE) TREE_LANG_FLAG_0 (NODE)
+
 /* Determine if this is an argument pack.  */
 #define ARGUMENT_PACK_P(NODE)                          \
   (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK              \
index ad2b4df..4c93b31 100644 (file)
@@ -3238,6 +3238,8 @@ make_pack_expansion (tree arg)
     }
   PACK_EXPANSION_PARAMETER_PACKS (result) = parameter_packs;
 
+  PACK_EXPANSION_LOCAL_P (result) = at_function_scope_p ();
+
   return result;
 }
 
@@ -9340,7 +9342,7 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
        }
       if (TREE_CODE (parm_pack) == PARM_DECL)
        {
-         if (at_function_scope_p ())
+         if (PACK_EXPANSION_LOCAL_P (t))
            arg_pack = retrieve_local_specialization (parm_pack);
          else
            {
@@ -18905,6 +18907,7 @@ tsubst_initializer_list (tree t, tree argvec)
           /* Build a dummy EXPR_PACK_EXPANSION that will be used to
              expand each argument in the TREE_VALUE of t.  */
           expr = make_node (EXPR_PACK_EXPANSION);
+         PACK_EXPANSION_LOCAL_P (expr) = true;
           PACK_EXPANSION_PARAMETER_PACKS (expr) =
             PACK_EXPANSION_PARAMETER_PACKS (TREE_PURPOSE (t));
 
index ae4175f..820175c 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-31  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52043
+       * g++.dg/cpp0x/variadic122.C: New.
+
 2012-01-31  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/52012
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic122.C b/gcc/testsuite/g++.dg/cpp0x/variadic122.C
new file mode 100644 (file)
index 0000000..7f03c10
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/52043
+// { dg-options "-std=c++11 -Wreturn-type" }
+
+template < class T > struct Container
+{
+  T f ();
+};
+
+template < class T >
+T deref (T)
+{}                             // { dg-warning "no return" }
+
+template < class T, class ... Args >
+auto deref (T u, int, Args ... args)->decltype (deref (u.f (), args ...))
+{}                             // { dg-warning "no return" }
+
+void
+foo ()
+{
+  Container < Container < int > > v;
+  deref (v, 2);
+}