re PR c++/33939 (Rvalue references not deduced correctly in vararg function templates)
authorDouglas Gregor <doug.gregor@gmail.com>
Mon, 5 Nov 2007 12:50:21 +0000 (12:50 +0000)
committerDoug Gregor <dgregor@gcc.gnu.org>
Mon, 5 Nov 2007 12:50:21 +0000 (12:50 +0000)
2007-11-05  Douglas Gregor  <doug.gregor@gmail.com>

PR c++/33939
* pt.c (unify_pack_expansion): bring handling of function call
arguments into line with type_unification_real.

2007-11-05  Douglas Gregor  <doug.gregor@gmail.com>

PR c++/33939
* g++.dg/cpp0x/variadic-rref.C: New.

From-SVN: r129900

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

index 78ff8f8e48e3633f96573ee11f3fe94bbefd9792..8923b24a21f01825a9ce4f63270d638d41317c23 100644 (file)
@@ -1,3 +1,9 @@
+2007-11-05  Douglas Gregor  <doug.gregor@gmail.com>
+
+       PR c++/33939
+       * pt.c (unify_pack_expansion): bring handling of function call
+       arguments into line with type_unification_real. 
+
 2007-11-05  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        * typeck.c (build_binary_op): Use pedwarn instead of error for
index e9e7789688111b1ed0a84fa0dfe53d79d147d344..9c29f81cc5d4b39701248bea1c2b460d97eed3f7 100644 (file)
@@ -12280,6 +12280,7 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
       /* Unify the pattern with the current argument.  */
       {
         tree arg = TREE_VEC_ELT (packed_args, i);
+       tree arg_expr = NULL_TREE;
         int arg_strict = strict;
         bool skip_arg_p = false;
 
@@ -12330,7 +12331,8 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
 
                 if (!skip_arg_p)
                   {
-                    arg = TREE_TYPE (arg);
+                   arg_expr = arg;
+                    arg = unlowered_expr_type (arg);
                     if (arg == error_mark_node)
                       return 1;
                   }
@@ -12340,7 +12342,8 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
 
             if (!subr)
               arg_strict |= 
-                maybe_adjust_types_for_deduction (strict, &parm, &arg, NULL);
+                maybe_adjust_types_for_deduction (strict, &parm, &arg, 
+                                                 arg_expr);
           }
 
         if (!skip_arg_p)
index 6817e837aabeb692b1f7afcc46e6923d1caadbfd..12dd3509259a39eddafae5bf7a3410ab8002a85d 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-05  Douglas Gregor  <doug.gregor@gmail.com>
+
+       PR c++/33939
+       * g++.dg/cpp0x/variadic-rref.C: New.
+       
 2007-11-05  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        * g++dg/warn/pointer-integer-comparison.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-rref.C b/gcc/testsuite/g++.dg/cpp0x/variadic-rref.C
new file mode 100644 (file)
index 0000000..08221b4
--- /dev/null
@@ -0,0 +1,36 @@
+// { dg-options "-std=c++0x" }
+// PR c++/33939
+template<typename T>
+struct refs_only;
+
+template<typename T>
+struct refs_only<T &>
+{};
+
+template<typename T>
+refs_only<T> foo( T && t)
+{
+    return refs_only<T>();
+}
+
+template<typename... T>
+struct va_refs_only;
+
+template<typename T>
+struct va_refs_only<T>
+  : refs_only<T>
+{};
+
+template<typename... T>
+va_refs_only<T...> bar( T &&... t)
+{
+    return va_refs_only<T...>();
+}
+
+int main()
+{
+    int j = 0;
+    foo(j);
+    bar(j); // error: invalid use of incomplete type 'struct refs_only<int>'
+}
+