This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++/v3 PATCHes for change in rvalue reference semantics


At the spring C++ meeting, the committee adopted a change (from paper N2831) to rvalue reference semantics such that lvalues will no longer bind to rvalue references; if you want to pass an lvalue to an rvalue reference argument, you need to use std::forward, std::move, or a static_cast to rvalue reference type. This is a safety measure, as with the old semantics code that worked properly under C++98 could silently start moving data out of your objects in C++0x.

Listing the patches in reverse order of application:

The first patch actually implements that change, as well as the changes to forward and move that it requires, and the new rvalue stream inserter/extractor also from N2831.

The second patch adds some library uses of move/forward that are now necessary, but are correct under the old rules as well, just not necessary.

The third patch fixes direct binding of rvalue references to rvalue reference-derived "rvalues", both in implicit conversion and static_cast. This too is correct under the old rules, but wasn't as necessary because it used to be handled by the lvalue conversion code.

The last patch isn't necessary for this semantic change, just something that's been nagging at me for a while, so I tried fixing it -- many places in the compiler use build_address to take the address of something while avoiding the errors that cp_build_unary_op gives. But for some reason the comment before build_address said that it did no folding at all. I tried making it fold away &*, and that worked fine. Similarly, using TYPE_MAIN_VARIANT to get a cv-unqualified type to use on an expression is wrong; we should only do that for type comparison.

Tested x86_64-pc-linux-gnu, applied to trunk.
2009-07-31  Jason Merrill  <jason@redhat.com>
	    Douglas Gregor  <doug.gregor@gmail.com>

	Remove implicit binding of lvalues to rvalue references (N2831)
gcc/cp:
	* call.c (convert_class_to_reference): Binding an lvalue to an
	rvalue reference is bad.  If the user-defined conversion is bad,
	set bad_p before merging conversions.
	(maybe_handle_ref_bind): Don't push down bad_p.
	(reference_binding): Binding an lvalue to an rvalue reference is bad.
	(convert_like_real): Give a helpful error about binding lvalue
	to rvalue reference.
	(reference_related_p): No longer static.
	* typeck.c (build_typed_address): New.
	(build_static_cast_1): Add static_cast from lvalue to &&.
	* cp-tree.h: Adjust.
libstdc++-v3:
	* include/bits/move.h (forward): Implement as in N2835.
	(move): Implement as in N2831.
	* include/std/istream (rvalue stream operator>>): New.
	* include/std/ostream (rvalue stream operator<<): New.
	* testsuite/27_io/rvalue_streams.cc: New.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 144d07e..a667434 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -190,7 +190,6 @@ static struct z_candidate *add_candidate
 	 conversion **, tree, tree, int);
 static tree source_type (conversion *);
 static void add_warning (struct z_candidate *, struct z_candidate *);
-static bool reference_related_p (tree, tree);
 static bool reference_compatible_p (tree, tree);
 static conversion *convert_class_to_reference (tree, tree, tree, int);
 static conversion *direct_reference_binding (tree, conversion *);
@@ -966,7 +965,7 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
 
 /* Returns nonzero if T1 is reference-related to T2.  */
 
-static bool
+bool
 reference_related_p (tree t1, tree t2)
 {
   t1 = TYPE_MAIN_VARIANT (t1);
@@ -1110,6 +1109,11 @@ convert_class_to_reference (tree reference_type, tree s, tree expr, int flags)
 		= TYPE_REF_IS_RVALUE (TREE_TYPE (TREE_TYPE (cand->fn)))
 		  == TYPE_REF_IS_RVALUE (reference_type);
 	      cand->second_conv->bad_p |= cand->convs[0]->bad_p;
+
+              /* Don't allow binding of lvalues to rvalue references.  */
+              if (TYPE_REF_IS_RVALUE (reference_type)
+                  && !TYPE_REF_IS_RVALUE (TREE_TYPE (TREE_TYPE (cand->fn))))
+                cand->second_conv->bad_p = true;
 	    }
 	}
     }
@@ -1137,13 +1141,13 @@ convert_class_to_reference (tree reference_type, tree s, tree expr, int flags)
 		     build_identity_conv (TREE_TYPE (expr), expr));
   conv->cand = cand;
 
+  if (cand->viable == -1)
+    conv->bad_p = true;
+
   /* Merge it with the standard conversion sequence from the
      conversion function's return type to the desired type.  */
   cand->second_conv = merge_conversion_sequences (conv, cand->second_conv);
 
-  if (cand->viable == -1)
-    conv->bad_p = true;
-
   return cand->second_conv;
 }
 
@@ -1308,6 +1312,11 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
 	   actually occurs.  */
 	conv->need_temporary_p = true;
 
+      /* Don't allow binding of lvalues to rvalue references.  */
+      if (is_lvalue && TYPE_REF_IS_RVALUE (rto)
+          && !(flags & LOOKUP_PREFER_RVALUE))
+	conv->bad_p = true;
+
       return conv;
     }
   /* [class.conv.fct] A conversion function is never used to convert a
@@ -4961,6 +4970,19 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
       {
 	tree ref_type = totype;
 
+	if (convs->bad_p && TYPE_REF_IS_RVALUE (ref_type)
+	    && real_lvalue_p (expr))
+	  {
+	    if (complain & tf_error)
+	      {
+		error ("cannot bind %qT lvalue to %qT",
+		       TREE_TYPE (expr), totype);
+		if (fn)
+		  error ("  initializing argument %P of %q+D", argnum, fn);
+	      }
+	    return error_mark_node;
+	  }
+
 	/* If necessary, create a temporary. 
 
            VA_ARG_EXPR and CONSTRUCTOR expressions are special cases
@@ -6459,7 +6481,6 @@ maybe_handle_ref_bind (conversion **ics)
       conversion *old_ics = *ics;
       *ics = old_ics->u.next;
       (*ics)->user_conv_p = old_ics->user_conv_p;
-      (*ics)->bad_p = old_ics->bad_p;
       return old_ics;
     }
 
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 07e89d3..c507ac8 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4266,6 +4266,7 @@ extern tree set_up_extended_ref_temp		(tree, tree, tree *, tree *);
 extern tree initialize_reference		(tree, tree, tree, tree *);
 extern tree make_temporary_var_for_ref_to_temp	(tree, tree);
 extern tree strip_top_quals			(tree);
+extern bool reference_related_p			(tree, tree);
 extern tree perform_implicit_conversion		(tree, tree, tsubst_flags_t);
 extern tree perform_implicit_conversion_flags	(tree, tree, tsubst_flags_t, int);
 extern tree perform_direct_initialization_if_possible (tree, tree, bool,
@@ -5062,6 +5063,7 @@ extern tree cp_build_binary_op                  (location_t,
 #define cxx_sizeof(T)  cxx_sizeof_or_alignof_type (T, SIZEOF_EXPR, true)
 extern tree build_ptrmemfunc_access_expr	(tree, tree);
 extern tree build_address			(tree);
+extern tree build_typed_address			(tree, tree);
 extern tree build_nop				(tree, tree);
 extern tree non_reference			(tree);
 extern tree lookup_anon_field			(tree, tree);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a956fdc..ef69f1d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4290,6 +4290,19 @@ build_address (tree t)
   return t;
 }
 
+/* Returns the address of T with type TYPE.  */
+
+tree
+build_typed_address (tree t, tree type)
+{
+  if (error_operand_p (t) || !cxx_mark_addressable (t))
+    return error_mark_node;
+  t = build_fold_addr_expr_with_type (t, type);
+  if (TREE_CODE (t) != ADDR_EXPR)
+    t = rvalue (t);
+  return t;
+}
+
 /* Return a NOP_EXPR converting EXPR to TYPE.  */
 
 tree
@@ -5313,6 +5326,18 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p,
       return convert_from_reference (cp_fold_convert (type, expr));
     }
 
+  /* "An lvalue of type cv1 T1 can be cast to type rvalue reference to
+     cv2 T2 if cv2 T2 is reference-compatible with cv1 T1 (8.5.3)."  */
+  if (TREE_CODE (type) == REFERENCE_TYPE
+      && TYPE_REF_IS_RVALUE (type)
+      && real_lvalue_p (expr)
+      && reference_related_p (TREE_TYPE (type), intype)
+      && (c_cast_p || at_least_as_qualified_p (TREE_TYPE (type), intype)))
+    {
+      expr = build_typed_address (expr, type);
+      return convert_from_reference (expr);
+    }
+
   orig = expr;
 
   /* [expr.static.cast]
diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h
index 25773e1..d1da1e4 100644
--- a/libstdc++-v3/include/bits/move.h
+++ b/libstdc++-v3/include/bits/move.h
@@ -46,12 +46,31 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       typedef _Tp type;
     };
 
-  /// forward
-  template<typename _Tp>
-    inline _Tp&&
+  /// forward (as per N2835)
+  /// Forward lvalues as rvalues.
+  template <class _Tp>
+    inline typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp&&>::type
+    forward(typename std::identity<_Tp>::type& __t)
+    { return static_cast<_Tp&&>(__t); }
+
+  /// Forward rvalues as rvalues.
+  template <class _Tp>
+    inline typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp&&>::type
     forward(typename std::identity<_Tp>::type&& __t)
+    { return static_cast<_Tp&&>(__t); }
+
+  // Forward lvalues as lvalues.
+  template <class _Tp>
+    inline typename enable_if<is_lvalue_reference<_Tp>::value, _Tp>::type
+    forward(typename std::identity<_Tp>::type __t)
     { return __t; }
 
+  // Prevent forwarding rvalues as const lvalues.
+  template <class _Tp>
+    inline typename enable_if<is_lvalue_reference<_Tp>::value, _Tp>::type
+    forward(typename std::remove_reference<_Tp>::type&& __t)
+    = delete;
+
   /**
    *  @brief Move a value.
    *  @ingroup mutating_algorithms
@@ -61,7 +80,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   template<typename _Tp>
     inline typename std::remove_reference<_Tp>::type&&
     move(_Tp&& __t)
-    { return __t; }
+    { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
 
 _GLIBCXX_END_NAMESPACE
 
diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream
index 1979a51..f20b896 100644
--- a/libstdc++-v3/include/std/istream
+++ b/libstdc++-v3/include/std/istream
@@ -827,6 +827,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     basic_istream<_CharT, _Traits>& 
     ws(basic_istream<_CharT, _Traits>& __is);
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  // [27.7.1.6] Rvalue stream extraction
+  /**
+   *  @brief  Generic extractor for rvalue stream
+   *  @param  is  An input stream.
+   *  @param  x  A reference to the extraction target.
+   *  @return  is
+   *
+   *  This is just a forwarding function to allow extraction from
+   *  rvalue streams since they won't bind to the extractor functions
+   *  that take an lvalue reference.
+  */
+  template<typename _CharT, typename _Traits, typename _Tp>
+  basic_istream<_CharT, _Traits>&
+  operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
+  {
+    __is >> __x;
+    return __is;
+  }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
 _GLIBCXX_END_NAMESPACE
 
 #ifndef _GLIBCXX_EXPORT_TEMPLATE
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index b9ea4a8..136c3d6 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -562,6 +562,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     flush(basic_ostream<_CharT, _Traits>& __os)
     { return __os.flush(); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  // [27.7.2.9] Rvalue stream insertion
+  /**
+   *  @brief  Generic inserter for rvalue stream
+   *  @param  os  An input stream.
+   *  @param  x  A reference to the object being inserted.
+   *  @return  os
+   *
+   *  This is just a forwarding function to allow insertion to
+   *  rvalue streams since they won't bind to the inserter functions
+   *  that take an lvalue reference.
+  */
+  template<typename _CharT, typename _Traits, typename _Tp>
+  basic_ostream<_CharT, _Traits>&
+  operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
+  {
+    __os << __x;
+    return __os;
+  }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
 _GLIBCXX_END_NAMESPACE
 
 #ifndef _GLIBCXX_EXPORT_TEMPLATE
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist22.C b/gcc/testsuite/g++.dg/cpp0x/initlist22.C
index bf1c554..0855b59 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist22.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist22.C
@@ -4,7 +4,7 @@
 int i;
 
 int& r1{ i };			// OK, direct binding
-int&& r2{ i };			// OK, direct binding
+int&& r2{ i };			// { dg-error "" } binding && to lvalue
 
 int& r3{ };			// { dg-error "" } reference to temporary
 int&& r4{ };			// OK, reference to temporary
diff --git a/gcc/testsuite/g++.dg/cpp0x/named.C b/gcc/testsuite/g++.dg/cpp0x/named.C
index b91e698..ef1a2fb 100644
--- a/gcc/testsuite/g++.dg/cpp0x/named.C
+++ b/gcc/testsuite/g++.dg/cpp0x/named.C
@@ -1,12 +1,17 @@
 // { dg-options "--std=c++0x" }
 // { dg-do link }
 
+template<typename _Tp>
+inline _Tp&&
+movel(_Tp& __t)
+{ return static_cast<_Tp&&>(__t); }
+
 struct S {};
 struct T
 {
-  T(S && s_) : s(s_) {}
-  S && get() { return s; }
-  operator S&&() { return s; }
+  T(S && s_) : s(movel(s_)) {}
+  S && get() { return movel(s); }
+  operator S&&() { return movel(s); }
   S && s;
 };
 
@@ -18,8 +23,8 @@ void unnamed(S&&) {}
 
 void f(S && p)
 {
-  S && s(p);
-  T t(s);
+  S && s(movel(p));
+  T t(movel(s));
 
   named(s);                          // variable reference
   named(p);                          // parameter reference
diff --git a/gcc/testsuite/g++.dg/cpp0x/overload.C b/gcc/testsuite/g++.dg/cpp0x/overload.C
index 945860c..3782d4a 100644
--- a/gcc/testsuite/g++.dg/cpp0x/overload.C
+++ b/gcc/testsuite/g++.dg/cpp0x/overload.C
@@ -2,6 +2,11 @@
 // { dg-do link }
 // Generated by overload.py
 
+template<typename _Tp>
+inline _Tp&&
+movel(_Tp& __t)
+{ return static_cast<_Tp&&>(__t); }
+
 struct S{};
 
 S l;                             // lvalue (l)
@@ -10,12 +15,12 @@ S r() { return l; }              // rvalue (r)
 S const cr() { return l; }       // const rvalue (cr)
 S & nl = l;                      // named lvalue reference (nl)
 S const & ncl = l;               // named const lvalue reference (ncl)
-S && nr = l;                     // named rvalue reference (nr)
-S const && ncr = l;              // named const rvalue reference (ncr)
+S && nr = movel(l);              // named rvalue reference (nr)
+S const && ncr = movel(l);       // named const rvalue reference (ncr)
 S & ul() { return l; }           // unnamed lvalue reference (ul)
 S const & ucl() { return l; }    // unnamed const lvalue reference (ucl)
-S && ur() { return l; }          // unnamed rvalue reference (ur)
-S const && ucr() { return l; }   // unnamed const rvalue reference (ucr)
+S && ur() { return movel(l); }   // unnamed rvalue reference (ur)
+S const && ucr() { return movel(l); } // unnamed const rvalue reference (ucr)
 
 void l0001(const S&&) {}
 
@@ -538,9 +543,9 @@ void ucr1111(const S&&) {}
 
 int main()
 {
-  l0001(l);
-  l0010(l);
-  l0011(l);
+  //l0001(l);
+  //l0010(l);
+  //l0011(l);
   l0100(l);
   l0101(l);
   l0110(l);
@@ -553,14 +558,14 @@ int main()
   l1101(l);
   l1110(l);
   l1111(l);
-  cl0001(cl);
-  cl0011(cl);
+  //cl0001(cl);
+  //cl0011(cl);
   cl0100(cl);
   cl0101(cl);
   cl0110(cl);
   cl0111(cl);
-  cl1001(cl);
-  cl1011(cl);
+  //cl1001(cl);
+  //cl1011(cl);
   cl1100(cl);
   cl1101(cl);
   cl1110(cl);
@@ -591,9 +596,9 @@ int main()
   cr1101(cr());
   cr1110(cr());
   cr1111(cr());
-  nl0001(nl);
-  nl0010(nl);
-  nl0011(nl);
+  //nl0001(nl);
+  //nl0010(nl);
+  //nl0011(nl);
   nl0100(nl);
   nl0101(nl);
   nl0110(nl);
@@ -606,21 +611,21 @@ int main()
   nl1101(nl);
   nl1110(nl);
   nl1111(nl);
-  ncl0001(ncl);
-  ncl0011(ncl);
+  //ncl0001(ncl);
+  //ncl0011(ncl);
   ncl0100(ncl);
   ncl0101(ncl);
   ncl0110(ncl);
   ncl0111(ncl);
-  ncl1001(ncl);
-  ncl1011(ncl);
+  //ncl1001(ncl);
+  //ncl1011(ncl);
   ncl1100(ncl);
   ncl1101(ncl);
   ncl1110(ncl);
   ncl1111(ncl);
-  nr0001(nr);
-  nr0010(nr);
-  nr0011(nr);
+  //nr0001(nr);
+  //nr0010(nr);
+  //nr0011(nr);
   nr0100(nr);
   nr0101(nr);
   nr0110(nr);
@@ -633,21 +638,21 @@ int main()
   nr1101(nr);
   nr1110(nr);
   nr1111(nr);
-  ncr0001(ncr);
-  ncr0011(ncr);
+  //ncr0001(ncr);
+  //ncr0011(ncr);
   ncr0100(ncr);
   ncr0101(ncr);
   ncr0110(ncr);
   ncr0111(ncr);
-  ncr1001(ncr);
-  ncr1011(ncr);
+  //ncr1001(ncr);
+  //ncr1011(ncr);
   ncr1100(ncr);
   ncr1101(ncr);
   ncr1110(ncr);
   ncr1111(ncr);
-  ul0001(ul());
-  ul0010(ul());
-  ul0011(ul());
+  //ul0001(ul());
+  //ul0010(ul());
+  //ul0011(ul());
   ul0100(ul());
   ul0101(ul());
   ul0110(ul());
@@ -660,14 +665,14 @@ int main()
   ul1101(ul());
   ul1110(ul());
   ul1111(ul());
-  ucl0001(ucl());
-  ucl0011(ucl());
+  //ucl0001(ucl());
+  //ucl0011(ucl());
   ucl0100(ucl());
   ucl0101(ucl());
   ucl0110(ucl());
   ucl0111(ucl());
-  ucl1001(ucl());
-  ucl1011(ucl());
+  //ucl1001(ucl());
+  //ucl1011(ucl());
   ucl1100(ucl());
   ucl1101(ucl());
   ucl1110(ucl());
diff --git a/gcc/testsuite/g++.dg/cpp0x/overloadn.C b/gcc/testsuite/g++.dg/cpp0x/overloadn.C
new file mode 100644
index 0000000..a42707f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/overloadn.C
@@ -0,0 +1,708 @@
+// { dg-options "--std=c++0x" }
+// { dg-do link }
+// Generated by overload.py
+
+template<typename _Tp>
+inline _Tp&&
+movel(_Tp& __t)
+{ return static_cast<_Tp&&>(__t); }
+
+struct S{};
+
+S l;                             // lvalue (l)
+S const cl = l;                  // const lvalue (cl)
+S r() { return l; }              // rvalue (r)
+S const cr() { return l; }       // const rvalue (cr)
+S & nl = l;                      // named lvalue reference (nl)
+S const & ncl = l;               // named const lvalue reference (ncl)
+S && nr = movel(l);              // named rvalue reference (nr)
+S const && ncr = movel(l);       // named const rvalue reference (ncr)
+S & ul() { return l; }           // unnamed lvalue reference (ul)
+S const & ucl() { return l; }    // unnamed const lvalue reference (ucl)
+S && ur() { return movel(l); }   // unnamed rvalue reference (ur)
+S const && ucr() { return movel(l); } // unnamed const rvalue reference (ucr)
+
+void l0001(const S&&) {} // { dg-message "" }
+
+void l0010(S&&) {} // { dg-message "" }
+
+void l0011(S&&) {} // { dg-message "" }
+void l0011(const S&&);
+
+void l0100(const S&) {}
+
+void l0101(const S&) {}
+void l0101(const S&&);
+
+void l0110(const S&) {}
+void l0110(S&&);
+
+void l0111(const S&) {}
+void l0111(S&&);
+void l0111(const S&&);
+
+void l1000(S&) {}
+
+void l1001(S&) {}
+void l1001(const S&&);
+
+void l1010(S&) {}
+void l1010(S&&);
+
+void l1011(S&) {}
+void l1011(S&&);
+void l1011(const S&&);
+
+void l1100(S&) {}
+void l1100(const S&);
+
+void l1101(S&) {}
+void l1101(const S&);
+void l1101(const S&&);
+
+void l1110(S&) {}
+void l1110(const S&);
+void l1110(S&&);
+
+void l1111(S&) {}
+void l1111(const S&);
+void l1111(S&&);
+void l1111(const S&&);
+
+void cl0001(const S&&) {} // { dg-message "" }
+
+void cl0011(S&&);
+void cl0011(const S&&) {} // { dg-message "" }
+
+void cl0100(const S&) {}
+
+void cl0101(const S&) {}
+void cl0101(const S&&);
+
+void cl0110(const S&) {}
+void cl0110(S&&);
+
+void cl0111(const S&) {}
+void cl0111(S&&);
+void cl0111(const S&&);
+
+void cl1001(S&);
+void cl1001(const S&&) {} // { dg-message "" }
+
+void cl1011(S&);
+void cl1011(S&&);
+void cl1011(const S&&) {} // { dg-message "" }
+
+void cl1100(S&);
+void cl1100(const S&) {}
+
+void cl1101(S&);
+void cl1101(const S&) {}
+void cl1101(const S&&);
+
+void cl1110(S&);
+void cl1110(const S&) {}
+void cl1110(S&&);
+
+void cl1111(S&);
+void cl1111(const S&) {}
+void cl1111(S&&);
+void cl1111(const S&&);
+
+void r0001(const S&&) {}
+
+void r0010(S&&) {}
+
+void r0011(S&&) {}
+void r0011(const S&&);
+
+void r0100(const S&) {}
+
+void r0101(const S&);
+void r0101(const S&&) {}
+
+void r0110(const S&);
+void r0110(S&&) {}
+
+void r0111(const S&);
+void r0111(S&&) {}
+void r0111(const S&&);
+
+void r1001(S&);
+void r1001(const S&&) {}
+
+void r1010(S&);
+void r1010(S&&) {}
+
+void r1011(S&);
+void r1011(S&&) {}
+void r1011(const S&&);
+
+void r1100(S&);
+void r1100(const S&) {}
+
+void r1101(S&);
+void r1101(const S&);
+void r1101(const S&&) {}
+
+void r1110(S&);
+void r1110(const S&);
+void r1110(S&&) {}
+
+void r1111(S&);
+void r1111(const S&);
+void r1111(S&&) {}
+void r1111(const S&&);
+
+void cr0001(const S&&) {}
+
+void cr0011(S&&);
+void cr0011(const S&&) {}
+
+void cr0100(const S&) {}
+
+void cr0101(const S&);
+void cr0101(const S&&) {}
+
+void cr0110(const S&) {}
+void cr0110(S&&);
+
+void cr0111(const S&);
+void cr0111(S&&);
+void cr0111(const S&&) {}
+
+void cr1001(S&);
+void cr1001(const S&&) {}
+
+void cr1011(S&);
+void cr1011(S&&);
+void cr1011(const S&&) {}
+
+void cr1100(S&);
+void cr1100(const S&) {}
+
+void cr1101(S&);
+void cr1101(const S&);
+void cr1101(const S&&) {}
+
+void cr1110(S&);
+void cr1110(const S&) {}
+void cr1110(S&&);
+
+void cr1111(S&);
+void cr1111(const S&);
+void cr1111(S&&);
+void cr1111(const S&&) {}
+
+void nl0001(const S&&) {} // { dg-message "" }
+
+void nl0010(S&&) {} // { dg-message "" }
+
+void nl0011(S&&) {} // { dg-message "" }
+void nl0011(const S&&);
+
+void nl0100(const S&) {}
+
+void nl0101(const S&) {}
+void nl0101(const S&&);
+
+void nl0110(const S&) {}
+void nl0110(S&&);
+
+void nl0111(const S&) {}
+void nl0111(S&&);
+void nl0111(const S&&);
+
+void nl1000(S&) {}
+
+void nl1001(S&) {}
+void nl1001(const S&&);
+
+void nl1010(S&) {}
+void nl1010(S&&);
+
+void nl1011(S&) {}
+void nl1011(S&&);
+void nl1011(const S&&);
+
+void nl1100(S&) {}
+void nl1100(const S&);
+
+void nl1101(S&) {}
+void nl1101(const S&);
+void nl1101(const S&&);
+
+void nl1110(S&) {}
+void nl1110(const S&);
+void nl1110(S&&);
+
+void nl1111(S&) {}
+void nl1111(const S&);
+void nl1111(S&&);
+void nl1111(const S&&);
+
+void ncl0001(const S&&) {} // { dg-message "" }
+
+void ncl0011(S&&);
+void ncl0011(const S&&) {} // { dg-message "" }
+
+void ncl0100(const S&) {}
+
+void ncl0101(const S&) {}
+void ncl0101(const S&&);
+
+void ncl0110(const S&) {}
+void ncl0110(S&&);
+
+void ncl0111(const S&) {}
+void ncl0111(S&&);
+void ncl0111(const S&&);
+
+void ncl1001(S&);
+void ncl1001(const S&&) {} // { dg-message "" }
+
+void ncl1011(S&);
+void ncl1011(S&&);
+void ncl1011(const S&&) {} // { dg-message "" }
+
+void ncl1100(S&);
+void ncl1100(const S&) {}
+
+void ncl1101(S&);
+void ncl1101(const S&) {}
+void ncl1101(const S&&);
+
+void ncl1110(S&);
+void ncl1110(const S&) {}
+void ncl1110(S&&);
+
+void ncl1111(S&);
+void ncl1111(const S&) {}
+void ncl1111(S&&);
+void ncl1111(const S&&);
+
+void nr0001(const S&&) {} // { dg-message "" }
+
+void nr0010(S&&) {} // { dg-message "" }
+
+void nr0011(S&&) {} // { dg-message "" }
+void nr0011(const S&&);
+
+void nr0100(const S&) {}
+
+void nr0101(const S&) {}
+void nr0101(const S&&);
+
+void nr0110(const S&) {}
+void nr0110(S&&);
+
+void nr0111(const S&) {}
+void nr0111(S&&);
+void nr0111(const S&&);
+
+void nr1000(S&) {}
+
+void nr1001(S&) {}
+void nr1001(const S&&);
+
+void nr1010(S&) {}
+void nr1010(S&&);
+
+void nr1011(S&) {}
+void nr1011(S&&);
+void nr1011(const S&&);
+
+void nr1100(S&) {}
+void nr1100(const S&);
+
+void nr1101(S&) {}
+void nr1101(const S&);
+void nr1101(const S&&);
+
+void nr1110(S&) {}
+void nr1110(const S&);
+void nr1110(S&&);
+
+void nr1111(S&) {}
+void nr1111(const S&);
+void nr1111(S&&);
+void nr1111(const S&&);
+
+void ncr0001(const S&&) {} // { dg-message "" }
+
+void ncr0011(S&&);
+void ncr0011(const S&&) {} // { dg-message "" }
+
+void ncr0100(const S&) {}
+
+void ncr0101(const S&) {}
+void ncr0101(const S&&);
+
+void ncr0110(const S&) {}
+void ncr0110(S&&);
+
+void ncr0111(const S&) {}
+void ncr0111(S&&);
+void ncr0111(const S&&);
+
+void ncr1001(S&);
+void ncr1001(const S&&) {} // { dg-message "" }
+
+void ncr1011(S&);
+void ncr1011(S&&);
+void ncr1011(const S&&) {} // { dg-message "" }
+
+void ncr1100(S&);
+void ncr1100(const S&) {}
+
+void ncr1101(S&);
+void ncr1101(const S&) {}
+void ncr1101(const S&&);
+
+void ncr1110(S&);
+void ncr1110(const S&) {}
+void ncr1110(S&&);
+
+void ncr1111(S&);
+void ncr1111(const S&) {}
+void ncr1111(S&&);
+void ncr1111(const S&&);
+
+void ul0001(const S&&) {} // { dg-message "" }
+
+void ul0010(S&&) {} // { dg-message "" }
+
+void ul0011(S&&) {} // { dg-message "" }
+void ul0011(const S&&);
+
+void ul0100(const S&) {}
+
+void ul0101(const S&) {}
+void ul0101(const S&&);
+
+void ul0110(const S&) {}
+void ul0110(S&&);
+
+void ul0111(const S&) {}
+void ul0111(S&&);
+void ul0111(const S&&);
+
+void ul1000(S&) {}
+
+void ul1001(S&) {}
+void ul1001(const S&&);
+
+void ul1010(S&) {}
+void ul1010(S&&);
+
+void ul1011(S&) {}
+void ul1011(S&&);
+void ul1011(const S&&);
+
+void ul1100(S&) {}
+void ul1100(const S&);
+
+void ul1101(S&) {}
+void ul1101(const S&);
+void ul1101(const S&&);
+
+void ul1110(S&) {}
+void ul1110(const S&);
+void ul1110(S&&);
+
+void ul1111(S&) {}
+void ul1111(const S&);
+void ul1111(S&&);
+void ul1111(const S&&);
+
+void ucl0001(const S&&) {} // { dg-message "" }
+
+void ucl0011(S&&);
+void ucl0011(const S&&) {} // { dg-message "" }
+
+void ucl0100(const S&) {}
+
+void ucl0101(const S&) {}
+void ucl0101(const S&&);
+
+void ucl0110(const S&) {}
+void ucl0110(S&&);
+
+void ucl0111(const S&) {}
+void ucl0111(S&&);
+void ucl0111(const S&&);
+
+void ucl1001(S&);
+void ucl1001(const S&&) {} // { dg-message "" }
+
+void ucl1011(S&);
+void ucl1011(S&&);
+void ucl1011(const S&&) {} // { dg-message "" }
+
+void ucl1100(S&);
+void ucl1100(const S&) {}
+
+void ucl1101(S&);
+void ucl1101(const S&) {}
+void ucl1101(const S&&);
+
+void ucl1110(S&);
+void ucl1110(const S&) {}
+void ucl1110(S&&);
+
+void ucl1111(S&);
+void ucl1111(const S&) {}
+void ucl1111(S&&);
+void ucl1111(const S&&);
+
+void ur0001(const S&&) {}
+
+void ur0010(S&&) {}
+
+void ur0011(S&&) {}
+void ur0011(const S&&);
+
+void ur0100(const S&) {}
+
+void ur0101(const S&);
+void ur0101(const S&&) {}
+
+void ur0110(const S&);
+void ur0110(S&&) {}
+
+void ur0111(const S&);
+void ur0111(S&&) {}
+void ur0111(const S&&);
+
+void ur1001(S&);
+void ur1001(const S&&) {}
+
+void ur1010(S&);
+void ur1010(S&&) {}
+
+void ur1011(S&);
+void ur1011(S&&) {}
+void ur1011(const S&&);
+
+void ur1100(S&);
+void ur1100(const S&) {}
+
+void ur1101(S&);
+void ur1101(const S&);
+void ur1101(const S&&) {}
+
+void ur1110(S&);
+void ur1110(const S&);
+void ur1110(S&&) {}
+
+void ur1111(S&);
+void ur1111(const S&);
+void ur1111(S&&) {}
+void ur1111(const S&&);
+
+void ucr0001(const S&&) {}
+
+void ucr0011(S&&);
+void ucr0011(const S&&) {}
+
+void ucr0100(const S&) {}
+
+void ucr0101(const S&);
+void ucr0101(const S&&) {}
+
+void ucr0110(const S&) {}
+void ucr0110(S&&);
+
+void ucr0111(const S&);
+void ucr0111(S&&);
+void ucr0111(const S&&) {}
+
+void ucr1001(S&);
+void ucr1001(const S&&) {}
+
+void ucr1011(S&);
+void ucr1011(S&&);
+void ucr1011(const S&&) {}
+
+void ucr1100(S&);
+void ucr1100(const S&) {}
+
+void ucr1101(S&);
+void ucr1101(const S&);
+void ucr1101(const S&&) {}
+
+void ucr1110(S&);
+void ucr1110(const S&) {}
+void ucr1110(S&&);
+
+void ucr1111(S&);
+void ucr1111(const S&);
+void ucr1111(S&&);
+void ucr1111(const S&&) {}
+
+
+int main()
+{
+  l0001(l); // { dg-error "lvalue" }
+  l0010(l); // { dg-error "lvalue" }
+  l0011(l); // { dg-error "lvalue" }
+  l0100(l);
+  l0101(l);
+  l0110(l);
+  l0111(l);
+  l1000(l);
+  l1001(l);
+  l1010(l);
+  l1011(l);
+  l1100(l);
+  l1101(l);
+  l1110(l);
+  l1111(l);
+  cl0001(cl); // { dg-error "lvalue" }
+  cl0011(cl); // { dg-error "lvalue" }
+  cl0100(cl);
+  cl0101(cl);
+  cl0110(cl);
+  cl0111(cl);
+  cl1001(cl); // { dg-error "lvalue" }
+  cl1011(cl); // { dg-error "lvalue" }
+  cl1100(cl);
+  cl1101(cl);
+  cl1110(cl);
+  cl1111(cl);
+  r0001(r());
+  r0010(r());
+  r0011(r());
+  r0100(r());
+  r0101(r());
+  r0110(r());
+  r0111(r());
+  r1001(r());
+  r1010(r());
+  r1011(r());
+  r1100(r());
+  r1101(r());
+  r1110(r());
+  r1111(r());
+  cr0001(cr());
+  cr0011(cr());
+  cr0100(cr());
+  cr0101(cr());
+  cr0110(cr());
+  cr0111(cr());
+  cr1001(cr());
+  cr1011(cr());
+  cr1100(cr());
+  cr1101(cr());
+  cr1110(cr());
+  cr1111(cr());
+  nl0001(nl); // { dg-error "lvalue" }
+  nl0010(nl); // { dg-error "lvalue" }
+  nl0011(nl); // { dg-error "lvalue" }
+  nl0100(nl);
+  nl0101(nl);
+  nl0110(nl);
+  nl0111(nl);
+  nl1000(nl);
+  nl1001(nl);
+  nl1010(nl);
+  nl1011(nl);
+  nl1100(nl);
+  nl1101(nl);
+  nl1110(nl);
+  nl1111(nl);
+  ncl0001(ncl); // { dg-error "lvalue" }
+  ncl0011(ncl); // { dg-error "lvalue" }
+  ncl0100(ncl);
+  ncl0101(ncl);
+  ncl0110(ncl);
+  ncl0111(ncl);
+  ncl1001(ncl); // { dg-error "lvalue" }
+  ncl1011(ncl); // { dg-error "lvalue" }
+  ncl1100(ncl);
+  ncl1101(ncl);
+  ncl1110(ncl);
+  ncl1111(ncl);
+  nr0001(nr); // { dg-error "lvalue" }
+  nr0010(nr); // { dg-error "lvalue" }
+  nr0011(nr); // { dg-error "lvalue" }
+  nr0100(nr);
+  nr0101(nr);
+  nr0110(nr);
+  nr0111(nr);
+  nr1000(nr);
+  nr1001(nr);
+  nr1010(nr);
+  nr1011(nr);
+  nr1100(nr);
+  nr1101(nr);
+  nr1110(nr);
+  nr1111(nr);
+  ncr0001(ncr); // { dg-error "lvalue" }
+  ncr0011(ncr); // { dg-error "lvalue" }
+  ncr0100(ncr);
+  ncr0101(ncr);
+  ncr0110(ncr);
+  ncr0111(ncr);
+  ncr1001(ncr); // { dg-error "lvalue" }
+  ncr1011(ncr); // { dg-error "lvalue" }
+  ncr1100(ncr);
+  ncr1101(ncr);
+  ncr1110(ncr);
+  ncr1111(ncr);
+  ul0001(ul()); // { dg-error "lvalue" }
+  ul0010(ul()); // { dg-error "lvalue" }
+  ul0011(ul()); // { dg-error "lvalue" }
+  ul0100(ul());
+  ul0101(ul());
+  ul0110(ul());
+  ul0111(ul());
+  ul1000(ul());
+  ul1001(ul());
+  ul1010(ul());
+  ul1011(ul());
+  ul1100(ul());
+  ul1101(ul());
+  ul1110(ul());
+  ul1111(ul());
+  ucl0001(ucl()); // { dg-error "lvalue" }
+  ucl0011(ucl()); // { dg-error "lvalue" }
+  ucl0100(ucl());
+  ucl0101(ucl());
+  ucl0110(ucl());
+  ucl0111(ucl());
+  ucl1001(ucl()); // { dg-error "lvalue" }
+  ucl1011(ucl()); // { dg-error "lvalue" }
+  ucl1100(ucl());
+  ucl1101(ucl());
+  ucl1110(ucl());
+  ucl1111(ucl());
+  ur0001(ur());
+  ur0010(ur());
+  ur0011(ur());
+  ur0100(ur());
+  ur0101(ur());
+  ur0110(ur());
+  ur0111(ur());
+  ur1001(ur());
+  ur1010(ur());
+  ur1011(ur());
+  ur1100(ur());
+  ur1101(ur());
+  ur1110(ur());
+  ur1111(ur());
+  ucr0001(ucr());
+  ucr0011(ucr());
+  ucr0100(ucr());
+  ucr0101(ucr());
+  ucr0110(ucr());
+  ucr0111(ucr());
+  ucr1001(ucr());
+  ucr1011(ucr());
+  ucr1100(ucr());
+  ucr1101(ucr());
+  ucr1110(ucr());
+  ucr1111(ucr());
+
+  return 0;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cast.C b/gcc/testsuite/g++.dg/cpp0x/rv-cast.C
new file mode 100644
index 0000000..48b7c13
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-cast.C
@@ -0,0 +1,6 @@
+// { dg-options "-std=c++0x" }
+
+void f(int i)
+{
+  int&& r = static_cast<int&&>(i);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv1n.C b/gcc/testsuite/g++.dg/cpp0x/rv1n.C
index 10b5dc2..b7b9b6e 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv1n.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv1n.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -103,6 +103,7 @@ int test1_5()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_1_5(a);		// { dg-error "lvalue" }
     sink_1_5(ca);           // { dg-error "invalid initialization" }
     sink_1_5(va);           // { dg-error "invalid initialization" }
     sink_1_5(cva);          // { dg-error "invalid initialization" }
@@ -120,6 +121,8 @@ int test1_6()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_1_6(a);		// { dg-error "lvalue" }
+    sink_1_6(ca);		// { dg-error "lvalue" }
     sink_1_6(va);           // { dg-error "invalid initialization" }
     sink_1_6(cva);          // { dg-error "invalid initialization" }
     sink_1_6(v_source());   // { dg-error "invalid initialization" }
@@ -135,13 +138,30 @@ int test1_7()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_1_7(a);	    // { dg-error "lvalue" }
     sink_1_7(ca);           // { dg-error "invalid initialization" }
+    sink_1_7(va);	    // { dg-error "lvalue" }
     sink_1_7(cva);          // { dg-error "invalid initialization" }
     sink_1_7(c_source());   // { dg-error "invalid initialization" }
     sink_1_7(cv_source());  // { dg-error "invalid initialization" }
     return 0;
 }
 
+eight sink_1_8(const volatile A&&); // { dg-error "" }
+
+int test1_8()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_1_8(a);		// { dg-error "lvalue" }
+    sink_1_8(ca);		// { dg-error "lvalue" }
+    sink_1_8(va);		// { dg-error "lvalue" }
+    sink_1_8(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 int main()
 {
     return test1_1() + test1_2() + test1_3() + test1_5() +
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv1p.C b/gcc/testsuite/g++.dg/cpp0x/rv1p.C
index 6241885..b2770ef 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv1p.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv1p.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -93,7 +93,6 @@ int test1_5()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_1_5(a))           == 5> t1;
     sa<sizeof(sink_1_5(source()))    == 5> t5;
     return 0;
 }
@@ -106,8 +105,6 @@ int test1_6()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_1_6(a))           == 6> t1;
-    sa<sizeof(sink_1_6(ca))          == 6> t2;
     sa<sizeof(sink_1_6(source()))    == 6> t5;
     sa<sizeof(sink_1_6(c_source()))  == 6> t6;
     return 0;
@@ -121,8 +118,6 @@ int test1_7()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_1_7(a))           == 7> t1;
-    sa<sizeof(sink_1_7(va))          == 7> t3;
     sa<sizeof(sink_1_7(source()))    == 7> t5;
     sa<sizeof(sink_1_7(v_source()))  == 7> t7;
     return 0;
@@ -136,10 +131,6 @@ int test1_8()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_1_8(a))           == 8> t1;
-    sa<sizeof(sink_1_8(ca))          == 8> t2;
-    sa<sizeof(sink_1_8(va))          == 8> t3;
-    sa<sizeof(sink_1_8(cva))         == 8> t4;
     sa<sizeof(sink_1_8(source()))    == 8> t5;
     sa<sizeof(sink_1_8(c_source()))  == 8> t6;
     sa<sizeof(sink_1_8(v_source()))  == 8> t7;
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv2n.C b/gcc/testsuite/g++.dg/cpp0x/rv2n.C
index a4c11c6..5eee82c 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv2n.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv2n.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -30,8 +30,8 @@ const volatile A cv_source();
 
 // 2 at a time
 
-one   sink_2_12(               A&);  // { dg-message "candidates" }
-two   sink_2_12(const          A&);  // { dg-message "note" }
+one   sink_2_12(               A&);  // { dg-message "candidates|argument" }
+two   sink_2_12(const          A&);  // { dg-message "note|argument" }
 
 int test2_12()
 {
@@ -46,8 +46,8 @@ int test2_12()
     return 0;
 }
 
-one   sink_2_13(               A&);  // { dg-message "candidates" }
-three sink_2_13(volatile       A&);  // { dg-message "note" }
+one   sink_2_13(               A&);  // { dg-message "candidates|argument" }
+three sink_2_13(volatile       A&);  // { dg-message "note|argument" }
 
 int test2_13()
 {
@@ -64,8 +64,8 @@ int test2_13()
     return 0;
 }
 
-one   sink_2_14(               A&);  // { dg-message "candidates" }
-four  sink_2_14(const volatile A&);  // { dg-message "note" }
+one   sink_2_14(               A&);  // { dg-message "candidates|argument" }
+four  sink_2_14(const volatile A&);  // { dg-message "note|argument" }
 
 int test2_14()
 {
@@ -80,8 +80,8 @@ int test2_14()
     return 0;
 }
 
-one   sink_2_15(               A&);  // { dg-message "candidates" }
-five  sink_2_15(               A&&);  // { dg-message "note" }
+one   sink_2_15(               A&);  // { dg-message "candidates|argument" }
+five  sink_2_15(               A&&);  // { dg-message "note|argument" }
 
 int test2_15()
 {
@@ -98,8 +98,8 @@ int test2_15()
     return 0;
 }
 
-one   sink_2_16(               A&);  // { dg-message "candidates" }
-six   sink_2_16(const          A&&);  // { dg-message "note" }
+one   sink_2_16(               A&);  // { dg-message "candidates|argument" }
+six   sink_2_16(const          A&&);  // { dg-message "note|argument" }
 
 int test2_16()
 {
@@ -107,6 +107,7 @@ int test2_16()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_2_16(ca);	     // { dg-error "lvalue" }
     sink_2_16(va);           // { dg-error "no match" }
     sink_2_16(cva);          // { dg-error "no match" }
     sink_2_16(v_source());   // { dg-error "no match" }
@@ -114,8 +115,8 @@ int test2_16()
     return 0;
 }
 
-one   sink_2_17(               A&);  // { dg-message "candidates" }
-seven sink_2_17(volatile       A&&);  // { dg-message "note" }
+one   sink_2_17(               A&);  // { dg-message "candidates|argument" }
+seven sink_2_17(volatile       A&&);  // { dg-message "note|argument" }
 
 int test2_17()
 {
@@ -124,14 +125,29 @@ int test2_17()
           volatile A va;
     const volatile A cva = a;
     sink_2_17(ca);           // { dg-error "no match" }
+    sink_2_17(va);           // { dg-error "lvalue" }
     sink_2_17(cva);          // { dg-error "no match" }
     sink_2_17(c_source());   // { dg-error "no match" }
     sink_2_17(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
-two   sink_2_23(const          A&);  // { dg-message "candidates" }
-three sink_2_23(volatile       A&);  // { dg-message "note" }
+one   sink_2_18(               A&);
+eight sink_2_18(const volatile A&&); // { dg-error "argument" }
+
+int test2_18()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_2_18(ca);		// { dg-error "lvalue" }
+    sink_2_18(va);		// { dg-error "lvalue" }
+    sink_2_18(cva);		// { dg-error "lvalue" }
+}
+
+two   sink_2_23(const          A&);  // { dg-message "candidates|argument" }
+three sink_2_23(volatile       A&);  // { dg-message "note|argument" }
 
 int test2_23()
 {
@@ -146,8 +162,8 @@ int test2_23()
     return 0;
 }
 
-two   sink_2_24(const          A&);  // { dg-message "candidates" }
-four  sink_2_24(const volatile A&);  // { dg-message "note" }
+two   sink_2_24(const          A&);  // { dg-message "candidates|argument" }
+four  sink_2_24(const volatile A&);  // { dg-message "note|argument" }
 
 int test2_24()
 {
@@ -161,7 +177,7 @@ int test2_24()
 }
 
 three sink_2_34(volatile       A&);  // { dg-message "candidate" }
-four  sink_2_34(const volatile A&);  // { dg-message "note" }
+four  sink_2_34(const volatile A&);  // { dg-message "note|argument" }
 
 int test2_34()
 {
@@ -177,7 +193,7 @@ int test2_34()
 }
 
 two   sink_2_25(const          A&);  // { dg-message "candidate" }
-five  sink_2_25(               A&&);  // { dg-message "note" }
+five  sink_2_25(               A&&);  // { dg-message "note|argument" }
 
 int test2_25()
 {
@@ -193,7 +209,7 @@ int test2_25()
 }
 
 two   sink_2_26(const          A&);  // { dg-message "candidate" }
-six   sink_2_26(const          A&&);  // { dg-message "note" }
+six   sink_2_26(const          A&&);  // { dg-message "note|argument" }
 
 int test2_26()
 {
@@ -209,7 +225,7 @@ int test2_26()
 }
 
 two   sink_2_27(const          A&);  // { dg-message "candidate" }
-seven sink_2_27(volatile       A&&);  // { dg-message "note" }
+seven sink_2_27(volatile       A&&);  // { dg-message "note|argument" }
 
 int test2_27()
 {
@@ -217,13 +233,27 @@ int test2_27()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_2_27(va);	     // { dg-error "lvalue" }
     sink_2_27(cva);          // { dg-error "no match" }
     sink_2_27(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+two   sink_2_28(const          A&);
+eight sink_2_28(const volatile A&&); // { dg-error "argument" }
+
+int test2_28()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_2_28(va);		// { dg-error "lvalue" }
+    sink_2_28(cva);		// { dg-error "lvalue" }
+}
+
 three sink_2_35(volatile       A&);  // { dg-message "candidate" }
-five  sink_2_35(               A&&);  // { dg-message "note" }
+five  sink_2_35(               A&&);  // { dg-message "note|argument" }
 
 int test2_35()
 {
@@ -240,7 +270,7 @@ int test2_35()
 }
 
 three sink_2_36(volatile       A&);  // { dg-message "candidate" }
-six   sink_2_36(const          A&&);  // { dg-message "note" }
+six   sink_2_36(const          A&&);  // { dg-message "note|argument" }
 
 int test2_36()
 {
@@ -248,6 +278,7 @@ int test2_36()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_2_36(ca);		// { dg-error "lvalue" }
     sink_2_36(cva);          // { dg-error "no match" }
     sink_2_36(v_source());   // { dg-error "no match" }
     sink_2_36(cv_source());  // { dg-error "no match" }
@@ -255,7 +286,7 @@ int test2_36()
 }
 
 three sink_2_37(volatile       A&);  // { dg-message "candidate" }
-seven sink_2_37(volatile       A&&);  // { dg-message "note" }
+seven sink_2_37(volatile       A&&);  // { dg-message "note|argument" }
 
 int test2_37()
 {
@@ -270,8 +301,21 @@ int test2_37()
     return 0;
 }
 
+three sink_2_38(volatile       A&);
+eight sink_2_38(const volatile A&&); // { dg-error "argument" }
+
+int test2_38()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_2_38(ca);		// { dg-error "lvalue" }
+    sink_2_38(cva);		// { dg-error "lvalue" }
+}
+
 four  sink_2_45(const volatile A&);   // { dg-message "candidate" }
-five  sink_2_45(               A&&);  // { dg-message "note" }
+five  sink_2_45(               A&&);  // { dg-message "note|argument" }
 
 int test2_45()
 {
@@ -286,7 +330,7 @@ int test2_45()
 }
 
 four  sink_2_46(const volatile A&);   // { dg-message "candidate" }
-six   sink_2_46(const          A&&);  // { dg-message "note" }
+six   sink_2_46(const          A&&);  // { dg-message "note|argument" }
 
 int test2_46()
 {
@@ -300,7 +344,7 @@ int test2_46()
 }
 
 four  sink_2_47(const volatile A&);   // { dg-message "candidate" }
-seven sink_2_47(volatile       A&&);  // { dg-message "note" }
+seven sink_2_47(volatile       A&&);  // { dg-message "note|argument" }
 
 int test2_47()
 {
@@ -313,8 +357,8 @@ int test2_47()
     return 0;
 }
 
-five  sink_2_56(               A&&);  // { dg-message "candidate" }
-six   sink_2_56(const          A&&);  // { dg-message "note" }
+five  sink_2_56(               A&&);  // { dg-message "candidate|argument" }
+six   sink_2_56(const          A&&);  // { dg-message "note|argument" }
 
 int test2_56()
 {
@@ -322,6 +366,8 @@ int test2_56()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_2_56(a);		// { dg-error "lvalue" }
+    sink_2_56(ca);		// { dg-error "lvalue" }
     sink_2_56(va);           // { dg-error "no match" }
     sink_2_56(cva);          // { dg-error "no match" }
     sink_2_56(v_source());   // { dg-error "no match" }
@@ -329,8 +375,8 @@ int test2_56()
     return 0;
 }
 
-five  sink_2_57(               A&&);  // { dg-message "candidate" }
-seven sink_2_57(volatile       A&&);  // { dg-message "note" }
+five  sink_2_57(               A&&);  // { dg-message "candidate|argument" }
+seven sink_2_57(volatile       A&&);  // { dg-message "note|argument" }
 
 int test2_57()
 {
@@ -338,6 +384,8 @@ int test2_57()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_2_57(a);		// { dg-error "lvalue" }
+    sink_2_57(va);		// { dg-error "lvalue" }
     sink_2_57(ca);           // { dg-error "no match" }
     sink_2_57(cva);          // { dg-error "no match" }
     sink_2_57(c_source());   // { dg-error "no match" }
@@ -345,8 +393,23 @@ int test2_57()
     return 0;
 }
 
-six   sink_2_67(const          A&&);  // { dg-message "candidate" }
-seven sink_2_67(volatile       A&&);  // { dg-message "note" }
+five  sink_2_58(               A&&); // { dg-error "argument" }
+eight sink_2_58(const volatile A&&); // { dg-error "argument" }
+
+int test2_58()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_2_58(a);		// { dg-error "lvalue" }
+    sink_2_58(ca);		// { dg-error "lvalue" }
+    sink_2_58(va);		// { dg-error "lvalue" }
+    sink_2_58(cva);		// { dg-error "lvalue" }
+}
+
+six   sink_2_67(const          A&&);  // { dg-message "candidate|argument" }
+seven sink_2_67(volatile       A&&);  // { dg-message "note|argument" }
 
 int test2_67()
 {
@@ -355,12 +418,44 @@ int test2_67()
           volatile A va;
     const volatile A cva = a;
     sink_2_67(a);            // { dg-error "ambiguous" }
+    sink_2_67(ca);	     // { dg-error "lvalue" }
+    sink_2_67(va);	     // { dg-error "lvalue" }
     sink_2_67(cva);          // { dg-error "no match" }
     sink_2_67(source());     // { dg-error "ambiguous" }
     sink_2_67(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+six   sink_2_68(const          A&&); // { dg-error "argument" }
+eight sink_2_68(const volatile A&&); // { dg-error "argument" }
+
+int test2_68()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_2_68(a);		// { dg-error "lvalue" }
+    sink_2_68(ca);		// { dg-error "lvalue" }
+    sink_2_68(va);		// { dg-error "lvalue" }
+    sink_2_68(cva);		// { dg-error "lvalue" }
+}
+
+seven sink_2_78(volatile       A&&); // { dg-error "argument" }
+eight sink_2_78(const volatile A&&); // { dg-error "argument" }
+
+int test2_78()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_2_78(a);		// { dg-error "lvalue" }
+    sink_2_78(ca);		// { dg-error "lvalue" }
+    sink_2_78(va);		// { dg-error "lvalue" }
+    sink_2_78(cva);		// { dg-error "lvalue" }
+}
+
 int main()
 {
     return test2_12() + test2_13() + test2_15() + test2_16() +
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv2p.C b/gcc/testsuite/g++.dg/cpp0x/rv2p.C
index 0d12aac..61c4fb0 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv2p.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv2p.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -100,7 +100,6 @@ int test2_16()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_2_16(a))           == 1> t1;
-    sa<sizeof(sink_2_16(ca))          == 6> t2;
     sa<sizeof(sink_2_16(source()))    == 6> t5;
     sa<sizeof(sink_2_16(c_source()))  == 6> t6;
     return 0;
@@ -116,7 +115,6 @@ int test2_17()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_2_17(a))           == 1> t1;
-    sa<sizeof(sink_2_17(va))          == 7> t3;
     sa<sizeof(sink_2_17(source()))    == 7> t5;
     sa<sizeof(sink_2_17(v_source()))  == 7> t7;
     return 0;
@@ -132,9 +130,6 @@ int test2_18()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_2_18(a))           == 1> t1;
-    sa<sizeof(sink_2_18(ca))          == 8> t2;
-    sa<sizeof(sink_2_18(va))          == 8> t3;
-    sa<sizeof(sink_2_18(cva))         == 8> t4;
     sa<sizeof(sink_2_18(source()))    == 8> t5;
     sa<sizeof(sink_2_18(c_source()))  == 8> t6;
     sa<sizeof(sink_2_18(v_source()))  == 8> t7;
@@ -221,7 +216,6 @@ int test2_27()
     const volatile A cva = a;
     sa<sizeof(sink_2_27(a))           == 2> t1;
     sa<sizeof(sink_2_27(ca))          == 2> t2;
-    sa<sizeof(sink_2_27(va))          == 7> t3;
     sa<sizeof(sink_2_27(source()))    == 7> t5;
     sa<sizeof(sink_2_27(c_source()))  == 2> t6;
     sa<sizeof(sink_2_27(v_source()))  == 7> t7;
@@ -239,8 +233,6 @@ int test2_28()
     const volatile A cva = a;
     sa<sizeof(sink_2_28(a))           == 2> t1;
     sa<sizeof(sink_2_28(ca))          == 2> t2;
-    sa<sizeof(sink_2_28(va))          == 8> t3;
-    sa<sizeof(sink_2_28(cva))         == 8> t4;
     sa<sizeof(sink_2_28(source()))    == 8> t5;
     sa<sizeof(sink_2_28(c_source()))  == 8> t6;
     sa<sizeof(sink_2_28(v_source()))  == 8> t7;
@@ -293,7 +285,6 @@ int test2_36()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_2_36(a))           == 3> t1;
-    sa<sizeof(sink_2_36(ca))          == 6> t2;
     sa<sizeof(sink_2_36(va))          == 3> t3;
     sa<sizeof(sink_2_36(source()))    == 6> t5;
     sa<sizeof(sink_2_36(c_source()))  == 6> t6;
@@ -326,9 +317,7 @@ int test2_38()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_2_38(a))           == 3> t1;
-    sa<sizeof(sink_2_38(ca))          == 8> t2;
     sa<sizeof(sink_2_38(va))          == 3> t3;
-    sa<sizeof(sink_2_38(cva))         == 8> t4;
     sa<sizeof(sink_2_38(source()))    == 8> t5;
     sa<sizeof(sink_2_38(c_source()))  == 8> t6;
     sa<sizeof(sink_2_38(v_source()))  == 8> t7;
@@ -425,8 +414,6 @@ int test2_56()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_2_56(a))           == 5> t1;
-    sa<sizeof(sink_2_56(ca))          == 6> t2;
     sa<sizeof(sink_2_56(source()))    == 5> t5;
     sa<sizeof(sink_2_56(c_source()))  == 6> t6;
     return 0;
@@ -441,8 +428,6 @@ int test2_57()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_2_57(a))           == 5> t1;
-    sa<sizeof(sink_2_57(va))          == 7> t3;
     sa<sizeof(sink_2_57(source()))    == 5> t5;
     sa<sizeof(sink_2_57(v_source()))  == 7> t7;
     return 0;
@@ -457,10 +442,6 @@ int test2_58()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_2_58(a))           == 5> t1;
-    sa<sizeof(sink_2_58(ca))          == 8> t2;
-    sa<sizeof(sink_2_58(va))          == 8> t3;
-    sa<sizeof(sink_2_58(cva))         == 8> t4;
     sa<sizeof(sink_2_58(source()))    == 5> t5;
     sa<sizeof(sink_2_58(c_source()))  == 8> t6;
     sa<sizeof(sink_2_58(v_source()))  == 8> t7;
@@ -477,8 +458,6 @@ int test2_67()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_2_67(ca))          == 6> t2;
-    sa<sizeof(sink_2_67(va))          == 7> t3;
     sa<sizeof(sink_2_67(c_source()))  == 6> t6;
     sa<sizeof(sink_2_67(v_source()))  == 7> t7;
     return 0;
@@ -493,10 +472,6 @@ int test2_68()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_2_68(a))           == 6> t1;
-    sa<sizeof(sink_2_68(ca))          == 6> t2;
-    sa<sizeof(sink_2_68(va))          == 8> t3;
-    sa<sizeof(sink_2_68(cva))         == 8> t4;
     sa<sizeof(sink_2_68(source()))    == 6> t5;
     sa<sizeof(sink_2_68(c_source()))  == 6> t6;
     sa<sizeof(sink_2_68(v_source()))  == 8> t7;
@@ -513,10 +488,6 @@ int test2_78()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_2_78(a))           == 7> t1;
-    sa<sizeof(sink_2_78(ca))          == 8> t2;
-    sa<sizeof(sink_2_78(va))          == 7> t3;
-    sa<sizeof(sink_2_78(cva))         == 8> t4;
     sa<sizeof(sink_2_78(source()))    == 7> t5;
     sa<sizeof(sink_2_78(c_source()))  == 8> t6;
     sa<sizeof(sink_2_78(v_source()))  == 7> t7;
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv3n.C b/gcc/testsuite/g++.dg/cpp0x/rv3n.C
index 84675b3..0c208ab 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv3n.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv3n.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -97,7 +97,7 @@ int test3_126()
 
 one   sink_3_127(               A&);  // { dg-message "candidates" }
 two   sink_3_127(const          A&);  // { dg-message "note" }
-seven sink_3_127(volatile       A&&);  // { dg-message "note" }
+seven sink_3_127(volatile       A&&);  // { dg-message "" }
 
 int test3_127()
 {
@@ -105,11 +105,27 @@ int test3_127()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_127(va);		// { dg-error "lvalue" }
     sink_3_127(cva);          // { dg-error "no match" }
     sink_3_127(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_3_128(               A&);
+two   sink_3_128(const          A&);
+eight sink_3_128(const volatile A&&); // { dg-message "" }
+
+int test3_128()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+
+    sink_3_128(va);		// { dg-error "lvalue" }
+    sink_3_128(cva);		// { dg-error "lvalue" }
+}
+
 one   sink_3_134(               A&);  // { dg-message "candidates" }
 three sink_3_134(volatile       A&);  // { dg-message "note" }
 four  sink_3_134(const volatile A&);  // { dg-message "note" }
@@ -147,7 +163,7 @@ int test3_135()
 
 one   sink_3_136(               A&);  // { dg-message "candidates" }
 three sink_3_136(volatile       A&);  // { dg-message "note" }
-six   sink_3_136(const          A&&);  // { dg-message "note" }
+six   sink_3_136(const          A&&);  // { dg-message "" }
 
 int test3_136()
 {
@@ -155,6 +171,7 @@ int test3_136()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_136(ca);		// { dg-error "lvalue" }
     sink_3_136(cva);          // { dg-error "no match" }
     sink_3_136(v_source());   // { dg-error "no match" }
     sink_3_136(cv_source());  // { dg-error "no match" }
@@ -178,6 +195,21 @@ int test3_137()
     return 0;
 }
 
+one   sink_3_138(               A&);
+three sink_3_138(volatile       A&);
+eight sink_3_138(const volatile A&&); // { dg-message "" }
+
+int test3_138()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_138(ca);		// { dg-error "lvalue" }
+    sink_3_138(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_3_145(               A&);  // { dg-message "candidates" }
 four  sink_3_145(const volatile A&);  // { dg-message "note" }
 five  sink_3_145(               A&&);  // { dg-message "note" }
@@ -226,7 +258,7 @@ int test3_147()
 
 one   sink_3_156(               A&);  // { dg-message "candidates" }
 five  sink_3_156(               A&&);  // { dg-message "note" }
-six   sink_3_156(const          A&&);  // { dg-message "note" }
+six   sink_3_156(const          A&&);  // { dg-message "" }
 
 int test3_156()
 {
@@ -234,6 +266,7 @@ int test3_156()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_156(ca);		// { dg-error "lvalue" }
     sink_3_156(va);           // { dg-error "no match" }
     sink_3_156(cva);          // { dg-error "no match" }
     sink_3_156(v_source());   // { dg-error "no match" }
@@ -243,7 +276,7 @@ int test3_156()
 
 one   sink_3_157(               A&);  // { dg-message "candidates" }
 five  sink_3_157(               A&&);  // { dg-message "note" }
-seven sink_3_157(volatile       A&&);  // { dg-message "note" }
+seven sink_3_157(volatile       A&&);  // { dg-message "" }
 
 int test3_157()
 {
@@ -252,15 +285,32 @@ int test3_157()
           volatile A va;
     const volatile A cva = a;
     sink_3_157(ca);           // { dg-error "no match" }
+    sink_3_157(va);	      // { dg-error "lvalue" }
     sink_3_157(cva);          // { dg-error "no match" }
     sink_3_157(c_source());   // { dg-error "no match" }
     sink_3_157(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_3_158(               A&);
+five  sink_3_158(               A&&);
+eight sink_3_158(const volatile A&&); // { dg-message "" }
+
+int test3_158()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_158(ca);		// { dg-error "lvalue" }
+    sink_3_158(va);		// { dg-error "lvalue" }
+    sink_3_158(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_3_167(               A&);  // { dg-message "candidates" }
-six   sink_3_167(const          A&&);  // { dg-message "note" }
-seven sink_3_167(volatile       A&&);  // { dg-message "note" }
+six   sink_3_167(const          A&&);  // { dg-message "" }
+seven sink_3_167(volatile       A&&);  // { dg-message "" }
 
 int test3_167()
 {
@@ -268,12 +318,46 @@ int test3_167()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_167(ca);		// { dg-error "lvalue" }
+    sink_3_167(va);		// { dg-error "lvalue" }
     sink_3_167(cva);          // { dg-error "no match" }
     sink_3_167(source());     // { dg-error "ambiguous" }
     sink_3_167(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_3_168(               A&);
+six   sink_3_168(const          A&&); // { dg-message "" }
+eight sink_3_168(const volatile A&&); // { dg-message "" }
+
+int test3_168()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_168(ca);		// { dg-error "lvalue" }
+    sink_3_168(va);		// { dg-error "lvalue" }
+    sink_3_168(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+one   sink_3_178(               A&);
+seven sink_3_178(volatile       A&&); // { dg-message "" }
+eight sink_3_178(const volatile A&&); // { dg-message "" }
+
+int test3_178()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_178(ca);		// { dg-error "lvalue" }
+    sink_3_178(va);		// { dg-error "lvalue" }
+    sink_3_178(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 two   sink_3_234(const          A&);  // { dg-message "candidates" }
 three sink_3_234(volatile       A&);  // { dg-message "note" }
 four  sink_3_234(const volatile A&);  // { dg-message "note" }
@@ -342,7 +426,7 @@ int test3_237()
 
 two   sink_3_238(const          A&);  // { dg-message "candidates" }
 three sink_3_238(volatile       A&);  // { dg-message "note" }
-eight sink_3_238(const volatile A&&);  // { dg-message "note" }
+eight sink_3_238(const volatile A&&);  // { dg-message "" }
 
 int test3_238()
 {
@@ -351,6 +435,7 @@ int test3_238()
           volatile A va;
     const volatile A cva = a;
     sink_3_238(a);  // { dg-error "ambiguous" }
+    sink_3_238(cva); // { dg-error "lvalue" }
     return 0;
 }
 
@@ -417,7 +502,7 @@ int test3_256()
 
 two   sink_3_257(const          A&);  // { dg-message "candidates" }
 five  sink_3_257(               A&&);  // { dg-message "note" }
-seven sink_3_257(volatile       A&&);  // { dg-message "note" }
+seven sink_3_257(volatile       A&&);  // { dg-message "" }
 
 int test3_257()
 {
@@ -425,14 +510,30 @@ int test3_257()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_257(va);		// { dg-error "lvalue" }
     sink_3_257(cva);          // { dg-error "no match" }
     sink_3_257(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+two   sink_3_258(const          A&);
+five  sink_3_258(               A&&);
+eight sink_3_258(const volatile A&&); // { dg-message "" }
+
+int test3_258()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_258(va);		// { dg-error "lvalue" }
+    sink_3_258(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 two   sink_3_267(const          A&);  // { dg-message "candidates" }
 six   sink_3_267(const          A&&);  // { dg-message "note" }
-seven sink_3_267(volatile       A&&);  // { dg-message "note" }
+seven sink_3_267(volatile       A&&);  // { dg-message "" }
 
 int test3_267()
 {
@@ -440,12 +541,43 @@ int test3_267()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_267(va);		// { dg-error "lvalue" }
     sink_3_267(cva);          // { dg-error "no match" }
     sink_3_267(source());     // { dg-error "ambiguous" }
     sink_3_267(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+two   sink_3_268(const          A&);
+six   sink_3_268(const          A&&);
+eight sink_3_268(const volatile A&&); // { dg-message "" }
+
+int test3_268()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_268(va);		// { dg-error "lvalue" }
+    sink_3_268(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+two   sink_3_278(const          A&);
+seven sink_3_278(volatile       A&&); // { dg-message "" }
+eight sink_3_278(const volatile A&&); // { dg-message "" }
+
+int test3_278()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_278(va);		// { dg-error "lvalue" }
+    sink_3_278(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 three sink_3_345(volatile       A&);  // { dg-message "candidates" }
 four  sink_3_345(const volatile A&);  // { dg-message "note" }
 five  sink_3_345(               A&&);  // { dg-message "note" }
@@ -494,7 +626,7 @@ int test3_347()
 
 three sink_3_356(volatile       A&);  // { dg-message "candidates" }
 five  sink_3_356(               A&&);  // { dg-message "note" }
-six   sink_3_356(const          A&&);  // { dg-message "note" }
+six   sink_3_356(const          A&&);  // { dg-message "" }
 
 int test3_356()
 {
@@ -502,6 +634,7 @@ int test3_356()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_356(ca);		// { dg-error "lvalue" }
     sink_3_356(cva);          // { dg-error "no match" }
     sink_3_356(v_source());   // { dg-error "no match" }
     sink_3_356(cv_source());  // { dg-error "no match" }
@@ -525,8 +658,23 @@ int test3_357()
     return 0;
 }
 
+three sink_3_358(volatile       A&);
+five  sink_3_358(               A&&);
+eight sink_3_358(const volatile A&&); // { dg-message "" }
+
+int test3_358()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_358(ca);		// { dg-error "lvalue" }
+    sink_3_358(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 three sink_3_367(volatile       A&);  // { dg-message "candidates" }
-six   sink_3_367(const          A&&);  // { dg-message "note" }
+six   sink_3_367(const          A&&);  // { dg-message "" }
 seven sink_3_367(volatile       A&&);  // { dg-message "note" }
 
 int test3_367()
@@ -535,12 +683,43 @@ int test3_367()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_367(ca);		// { dg-error "lvalue" }
     sink_3_367(cva);          // { dg-error "no match" }
     sink_3_367(source());     // { dg-error "ambiguous" }
     sink_3_367(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+three sink_3_368(volatile       A&);
+six   sink_3_368(const          A&&); // { dg-message "" }
+eight sink_3_368(const volatile A&&); // { dg-message "" }
+
+int test3_368()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_368(ca);		// { dg-error "lvalue" }
+    sink_3_368(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+three sink_3_378(volatile       A&);
+seven sink_3_378(volatile       A&&);
+eight sink_3_378(const volatile A&&); // { dg-message "" }
+
+int test3_378()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_378(ca);		// { dg-error "lvalue" }
+    sink_3_378(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 four  sink_3_456(const volatile A&);  // { dg-message "candidates" }
 five  sink_3_456(               A&&);  // { dg-message "note" }
 six   sink_3_456(const          A&&);  // { dg-message "note" }
@@ -586,9 +765,9 @@ int test3_467()
     return 0;
 }
 
-five  sink_3_567(               A&&);  // { dg-message "candidates" }
-six   sink_3_567(const          A&&);  // { dg-message "note" }
-seven sink_3_567(volatile       A&&);  // { dg-message "note" }
+five  sink_3_567(               A&&);  // { dg-message "" }
+six   sink_3_567(const          A&&);  // { dg-message "" }
+seven sink_3_567(volatile       A&&);  // { dg-message "" }
 
 int test3_567()
 {
@@ -596,14 +775,51 @@ int test3_567()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_3_567(a);		// { dg-error "lvalue" }
+    sink_3_567(ca);		// { dg-error "lvalue" }
+    sink_3_567(va);		// { dg-error "lvalue" }
     sink_3_567(cva);          // { dg-error "no match" }
     sink_3_567(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
-six   sink_3_678(const          A&&);  // { dg-message "candidates" }
-seven sink_3_678(volatile       A&&);  // { dg-message "note" }
-eight sink_3_678(const volatile A&&);  // { dg-message "note" }
+five  sink_3_568(               A&&); // { dg-message "" }
+six   sink_3_568(const          A&&); // { dg-message "" }
+eight sink_3_568(const volatile A&&); // { dg-message "" }
+
+int test3_568()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_568(a);		// { dg-error "lvalue" }
+    sink_3_568(ca);		// { dg-error "lvalue" }
+    sink_3_568(va);		// { dg-error "lvalue" }
+    sink_3_568(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+five  sink_3_578(               A&&); // { dg-message "" }
+seven sink_3_578(volatile       A&&); // { dg-message "" }
+eight sink_3_578(const volatile A&&); // { dg-message "" }
+
+int test3_578()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_3_578(a);		// { dg-error "lvalue" }
+    sink_3_578(ca);		// { dg-error "lvalue" }
+    sink_3_578(va);		// { dg-error "lvalue" }
+    sink_3_578(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+six   sink_3_678(const          A&&);  // { dg-message "" }
+seven sink_3_678(volatile       A&&);  // { dg-message "" }
+eight sink_3_678(const volatile A&&);  // { dg-message "" }
 
 int test3_678()
 {
@@ -612,6 +828,9 @@ int test3_678()
           volatile A va;
     const volatile A cva = a;
     sink_3_678(a);          // { dg-error "ambiguous" }
+    sink_3_678(ca);	    // { dg-error "lvalue" }
+    sink_3_678(va);	    // { dg-error "lvalue" }
+    sink_3_678(cva);	    // { dg-error "lvalue" }
     sink_3_678(source());   // { dg-error "ambiguous" }
     return 0;
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv3p.C b/gcc/testsuite/g++.dg/cpp0x/rv3p.C
index c688b11..5ab171f 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv3p.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv3p.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -113,7 +113,6 @@ int test3_127()
     const volatile A cva = a;
     sa<sizeof(sink_3_127(a))           == 1> t1;
     sa<sizeof(sink_3_127(ca))          == 2> t2;
-    sa<sizeof(sink_3_127(va))          == 7> t3;
     sa<sizeof(sink_3_127(source()))    == 7> t5;
     sa<sizeof(sink_3_127(c_source()))  == 2> t6;
     sa<sizeof(sink_3_127(v_source()))  == 7> t7;
@@ -132,8 +131,6 @@ int test3_128()
     const volatile A cva = a;
     sa<sizeof(sink_3_128(a))           == 1> t1;
     sa<sizeof(sink_3_128(ca))          == 2> t2;
-    sa<sizeof(sink_3_128(va))          == 8> t3;
-    sa<sizeof(sink_3_128(cva))         == 8> t4;
     sa<sizeof(sink_3_128(source()))    == 8> t5;
     sa<sizeof(sink_3_128(c_source()))  == 8> t6;
     sa<sizeof(sink_3_128(v_source()))  == 8> t7;
@@ -185,7 +182,6 @@ int test3_136()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_136(a))           == 1> t1;
-    sa<sizeof(sink_3_136(ca))          == 6> t2;
     sa<sizeof(sink_3_136(va))          == 3> t3;
     sa<sizeof(sink_3_136(source()))    == 6> t5;
     sa<sizeof(sink_3_136(c_source()))  == 6> t6;
@@ -220,9 +216,7 @@ int test3_138()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_138(a))           == 1> t1;
-    sa<sizeof(sink_3_138(ca))          == 8> t2;
     sa<sizeof(sink_3_138(va))          == 3> t3;
-    sa<sizeof(sink_3_138(cva))         == 8> t4;
     sa<sizeof(sink_3_138(source()))    == 8> t5;
     sa<sizeof(sink_3_138(c_source()))  == 8> t6;
     sa<sizeof(sink_3_138(v_source()))  == 8> t7;
@@ -318,7 +312,6 @@ int test3_156()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_156(a))           == 1> t1;
-    sa<sizeof(sink_3_156(ca))          == 6> t2;
     sa<sizeof(sink_3_156(source()))    == 5> t5;
     sa<sizeof(sink_3_156(c_source()))  == 6> t6;
     return 0;
@@ -335,7 +328,6 @@ int test3_157()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_157(a))           == 1> t1;
-    sa<sizeof(sink_3_157(va))          == 7> t3;
     sa<sizeof(sink_3_157(source()))    == 5> t5;
     sa<sizeof(sink_3_157(v_source()))  == 7> t7;
     return 0;
@@ -352,9 +344,6 @@ int test3_158()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_158(a))           == 1> t1;
-    sa<sizeof(sink_3_158(ca))          == 8> t2;
-    sa<sizeof(sink_3_158(va))          == 8> t3;
-    sa<sizeof(sink_3_158(cva))         == 8> t4;
     sa<sizeof(sink_3_158(source()))    == 5> t5;
     sa<sizeof(sink_3_158(c_source()))  == 8> t6;
     sa<sizeof(sink_3_158(v_source()))  == 8> t7;
@@ -373,8 +362,6 @@ int test3_167()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_167(a))           == 1> t1;
-    sa<sizeof(sink_3_167(ca))          == 6> t2;
-    sa<sizeof(sink_3_167(va))          == 7> t3;
     sa<sizeof(sink_3_167(c_source()))  == 6> t6;
     sa<sizeof(sink_3_167(v_source()))  == 7> t7;
     return 0;
@@ -391,9 +378,6 @@ int test3_168()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_168(a))           == 1> t1;
-    sa<sizeof(sink_3_168(ca))          == 6> t2;
-    sa<sizeof(sink_3_168(va))          == 8> t3;
-    sa<sizeof(sink_3_168(cva))         == 8> t4;
     sa<sizeof(sink_3_168(source()))    == 6> t5;
     sa<sizeof(sink_3_168(c_source()))  == 6> t6;
     sa<sizeof(sink_3_168(v_source()))  == 8> t7;
@@ -412,9 +396,6 @@ int test3_178()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_178(a))           == 1> t1;
-    sa<sizeof(sink_3_178(ca))          == 8> t2;
-    sa<sizeof(sink_3_178(va))          == 7> t3;
-    sa<sizeof(sink_3_178(cva))         == 8> t4;
     sa<sizeof(sink_3_178(source()))    == 7> t5;
     sa<sizeof(sink_3_178(c_source()))  == 8> t6;
     sa<sizeof(sink_3_178(v_source()))  == 7> t7;
@@ -504,7 +485,6 @@ int test3_238()
     const volatile A cva = a;
     sa<sizeof(sink_3_238(ca))          == 2> t2;
     sa<sizeof(sink_3_238(va))          == 3> t3;
-    sa<sizeof(sink_3_238(cva))         == 8> t4;
     sa<sizeof(sink_3_238(source()))    == 8> t5;
     sa<sizeof(sink_3_238(c_source()))  == 8> t6;
     sa<sizeof(sink_3_238(v_source()))  == 8> t7;
@@ -620,7 +600,6 @@ int test3_257()
     const volatile A cva = a;
     sa<sizeof(sink_3_257(a))           == 2> t1;
     sa<sizeof(sink_3_257(ca))          == 2> t2;
-    sa<sizeof(sink_3_257(va))          == 7> t3;
     sa<sizeof(sink_3_257(source()))    == 5> t5;
     sa<sizeof(sink_3_257(c_source()))  == 2> t6;
     sa<sizeof(sink_3_257(v_source()))  == 7> t7;
@@ -639,8 +618,6 @@ int test3_258()
     const volatile A cva = a;
     sa<sizeof(sink_3_258(a))           == 2> t1;
     sa<sizeof(sink_3_258(ca))          == 2> t2;
-    sa<sizeof(sink_3_258(va))          == 8> t3;
-    sa<sizeof(sink_3_258(cva))         == 8> t4;
     sa<sizeof(sink_3_258(source()))    == 5> t5;
     sa<sizeof(sink_3_258(c_source()))  == 8> t6;
     sa<sizeof(sink_3_258(v_source()))  == 8> t7;
@@ -660,7 +637,6 @@ int test3_267()
     const volatile A cva = a;
     sa<sizeof(sink_3_267(a))           == 2> t1;
     sa<sizeof(sink_3_267(ca))          == 2> t2;
-    sa<sizeof(sink_3_267(va))          == 7> t3;
     sa<sizeof(sink_3_267(c_source()))  == 6> t6;
     sa<sizeof(sink_3_267(v_source()))  == 7> t7;
     return 0;
@@ -678,8 +654,6 @@ int test3_268()
     const volatile A cva = a;
     sa<sizeof(sink_3_268(a))           == 2> t1;
     sa<sizeof(sink_3_268(ca))          == 2> t2;
-    sa<sizeof(sink_3_268(va))          == 8> t3;
-    sa<sizeof(sink_3_268(cva))         == 8> t4;
     sa<sizeof(sink_3_268(source()))    == 6> t5;
     sa<sizeof(sink_3_268(c_source()))  == 6> t6;
     sa<sizeof(sink_3_268(v_source()))  == 8> t7;
@@ -699,8 +673,6 @@ int test3_278()
     const volatile A cva = a;
     sa<sizeof(sink_3_278(a))           == 2> t1;
     sa<sizeof(sink_3_278(ca))          == 2> t2;
-    sa<sizeof(sink_3_278(va))          == 7> t3;
-    sa<sizeof(sink_3_278(cva))         == 8> t4;
     sa<sizeof(sink_3_278(source()))    == 7> t5;
     sa<sizeof(sink_3_278(c_source()))  == 8> t6;
     sa<sizeof(sink_3_278(v_source()))  == 7> t7;
@@ -796,7 +768,6 @@ int test3_356()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_356(a))           == 3> t1;
-    sa<sizeof(sink_3_356(ca))          == 6> t2;
     sa<sizeof(sink_3_356(va))          == 3> t3;
     sa<sizeof(sink_3_356(source()))    == 5> t5;
     sa<sizeof(sink_3_356(c_source()))  == 6> t6;
@@ -831,9 +802,7 @@ int test3_358()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_358(a))           == 3> t1;
-    sa<sizeof(sink_3_358(ca))          == 8> t2;
     sa<sizeof(sink_3_358(va))          == 3> t3;
-    sa<sizeof(sink_3_358(cva))         == 8> t4;
     sa<sizeof(sink_3_358(source()))    == 5> t5;
     sa<sizeof(sink_3_358(c_source()))  == 8> t6;
     sa<sizeof(sink_3_358(v_source()))  == 8> t7;
@@ -852,7 +821,6 @@ int test3_367()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_367(a))           == 3> t1;
-    sa<sizeof(sink_3_367(ca))          == 6> t2;
     sa<sizeof(sink_3_367(va))          == 3> t3;
     sa<sizeof(sink_3_367(c_source()))  == 6> t6;
     sa<sizeof(sink_3_367(v_source()))  == 7> t7;
@@ -870,9 +838,7 @@ int test3_368()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_368(a))           == 3> t1;
-    sa<sizeof(sink_3_368(ca))          == 6> t2;
     sa<sizeof(sink_3_368(va))          == 3> t3;
-    sa<sizeof(sink_3_368(cva))         == 8> t4;
     sa<sizeof(sink_3_368(source()))    == 6> t5;
     sa<sizeof(sink_3_368(c_source()))  == 6> t6;
     sa<sizeof(sink_3_368(v_source()))  == 8> t7;
@@ -891,9 +857,7 @@ int test3_378()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_3_378(a))           == 3> t1;
-    sa<sizeof(sink_3_378(ca))          == 8> t2;
     sa<sizeof(sink_3_378(va))          == 3> t3;
-    sa<sizeof(sink_3_378(cva))         == 8> t4;
     sa<sizeof(sink_3_378(source()))    == 7> t5;
     sa<sizeof(sink_3_378(c_source()))  == 8> t6;
     sa<sizeof(sink_3_378(v_source()))  == 7> t7;
@@ -1031,9 +995,6 @@ int test3_567()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_3_567(a))           == 5> t1;
-    sa<sizeof(sink_3_567(ca))          == 6> t2;
-    sa<sizeof(sink_3_567(va))          == 7> t3;
     sa<sizeof(sink_3_567(source()))    == 5> t5;
     sa<sizeof(sink_3_567(c_source()))  == 6> t6;
     sa<sizeof(sink_3_567(v_source()))  == 7> t7;
@@ -1050,10 +1011,6 @@ int test3_568()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_3_568(a))           == 5> t1;
-    sa<sizeof(sink_3_568(ca))          == 6> t2;
-    sa<sizeof(sink_3_568(va))          == 8> t3;
-    sa<sizeof(sink_3_568(cva))         == 8> t4;
     sa<sizeof(sink_3_568(source()))    == 5> t5;
     sa<sizeof(sink_3_568(c_source()))  == 6> t6;
     sa<sizeof(sink_3_568(v_source()))  == 8> t7;
@@ -1071,10 +1028,6 @@ int test3_578()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_3_578(a))           == 5> t1;
-    sa<sizeof(sink_3_578(ca))          == 8> t2;
-    sa<sizeof(sink_3_578(va))          == 7> t3;
-    sa<sizeof(sink_3_578(cva))         == 8> t4;
     sa<sizeof(sink_3_578(source()))    == 5> t5;
     sa<sizeof(sink_3_578(c_source()))  == 8> t6;
     sa<sizeof(sink_3_578(v_source()))  == 7> t7;
@@ -1092,9 +1045,6 @@ int test3_678()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_3_678(ca))          == 6> t2;
-    sa<sizeof(sink_3_678(va))          == 7> t3;
-    sa<sizeof(sink_3_678(cva))         == 8> t4;
     sa<sizeof(sink_3_678(c_source()))  == 6> t6;
     sa<sizeof(sink_3_678(v_source()))  == 7> t7;
     sa<sizeof(sink_3_678(cv_source())) == 8> t8;
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv4n.C b/gcc/testsuite/g++.dg/cpp0x/rv4n.C
index b88e3f7..cf627ae 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv4n.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv4n.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -96,6 +96,21 @@ int test4_1237()
     return 0;
 }
 
+one   sink_4_1238(               A&);
+two   sink_4_1238(const          A&);
+three sink_4_1238(volatile       A&);
+eight sink_4_1238(const volatile A&&); // { dg-message "" }
+
+int test4_1238()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1238(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_4_1245(               A&);  // { dg-message "candidates" }
 two   sink_4_1245(const          A&);  // { dg-message "note" }
 four  sink_4_1245(const volatile A&);  // { dg-message "note" }
@@ -164,7 +179,7 @@ int test4_1256()
 one   sink_4_1257(               A&);  // { dg-message "candidates" }
 two   sink_4_1257(const          A&);  // { dg-message "note" }
 five  sink_4_1257(               A&&);  // { dg-message "note" }
-seven sink_4_1257(volatile       A&&);  // { dg-message "note" }
+seven sink_4_1257(volatile       A&&);  // { dg-message "" }
 
 int test4_1257()
 {
@@ -172,15 +187,32 @@ int test4_1257()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_1257(va);		// { dg-error "lvalue" }
     sink_4_1257(cva);          // { dg-error "no match" }
     sink_4_1257(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_4_1258(               A&);
+two   sink_4_1258(const          A&);
+five  sink_4_1258(               A&&);
+eight sink_4_1258(const volatile A&&); // { dg-message "" }
+
+int test4_1258()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1258(va);		// { dg-error "lvalue" }
+    sink_4_1258(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_4_1267(               A&);  // { dg-message "candidates" }
 two   sink_4_1267(const          A&);  // { dg-message "note" }
 six   sink_4_1267(const          A&&);  // { dg-message "note" }
-seven sink_4_1267(volatile       A&&);  // { dg-message "note" }
+seven sink_4_1267(volatile       A&&);  // { dg-message "" }
 
 int test4_1267()
 {
@@ -188,12 +220,45 @@ int test4_1267()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_1267(va);		// { dg-error "lvalue" }
     sink_4_1267(cva);          // { dg-error "no match" }
     sink_4_1267(source());     // { dg-error "ambiguous" }
     sink_4_1267(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_4_1268(               A&);
+two   sink_4_1268(const          A&);
+six   sink_4_1268(const          A&&);
+eight sink_4_1268(const volatile A&&); // { dg-message "" }
+
+int test4_1268()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1268(va);		// { dg-error "lvalue" }
+    sink_4_1268(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+one   sink_4_1278(               A&);
+two   sink_4_1278(const          A&);
+seven sink_4_1278(volatile       A&&); // { dg-message "" }
+eight sink_4_1278(const volatile A&&); // { dg-message "" }
+
+int test4_1278()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1278(va);		// { dg-error "lvalue" }
+    sink_4_1278(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_4_1345(               A&);  // { dg-message "candidates" }
 three sink_4_1345(volatile       A&);  // { dg-message "note" }
 four  sink_4_1345(const volatile A&);  // { dg-message "note" }
@@ -246,7 +311,7 @@ int test4_1347()
 one   sink_4_1356(               A&);  // { dg-message "candidates" }
 three sink_4_1356(volatile       A&);  // { dg-message "note" }
 five  sink_4_1356(               A&&);  // { dg-message "note" }
-six   sink_4_1356(const          A&&);  // { dg-message "note" }
+six   sink_4_1356(const          A&&);  // { dg-message "" }
 
 int test4_1356()
 {
@@ -254,6 +319,7 @@ int test4_1356()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_1356(ca);		// { dg-error "lvalue" }
     sink_4_1356(cva);          // { dg-error "no match" }
     sink_4_1356(v_source());   // { dg-error "no match" }
     sink_4_1356(cv_source());  // { dg-error "no match" }
@@ -278,9 +344,25 @@ int test4_1357()
     return 0;
 }
 
+one   sink_4_1358(               A&);
+three sink_4_1358(volatile       A&);
+five  sink_4_1358(               A&&);
+eight sink_4_1358(const volatile A&&); // { dg-message "" }
+
+int test4_1358()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1358(ca);		// { dg-error "lvalue" }
+    sink_4_1358(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_4_1367(               A&);  // { dg-message "candidates" }
 three sink_4_1367(volatile       A&);  // { dg-message "note" }
-six   sink_4_1367(const          A&&);  // { dg-message "note" }
+six   sink_4_1367(const          A&&);  // { dg-message "" }
 seven sink_4_1367(volatile       A&&);  // { dg-message "note" }
 
 int test4_1367()
@@ -289,12 +371,45 @@ int test4_1367()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_1367(ca);		// { dg-error "lvalue" }
     sink_4_1367(cva);          // { dg-error "no match" }
     sink_4_1367(source());     // { dg-error "ambiguous" }
     sink_4_1367(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_4_1368(               A&);
+three sink_4_1368(volatile       A&);
+six   sink_4_1368(const          A&&); // { dg-message "" }
+eight sink_4_1368(const volatile A&&); // { dg-message "" }
+
+int test4_1368()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1368(ca);		// { dg-error "lvalue" }
+    sink_4_1368(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+one   sink_4_1378(               A&);
+three sink_4_1378(volatile       A&);
+seven sink_4_1378(volatile       A&&);
+eight sink_4_1378(const volatile A&&); // { dg-message "" }
+
+int test4_1378()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1378(ca);		// { dg-error "lvalue" }
+    sink_4_1378(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_4_1456(               A&);  // { dg-message "candidates" }
 four  sink_4_1456(const volatile A&);  // { dg-message "note" }
 five  sink_4_1456(               A&&);  // { dg-message "note" }
@@ -345,8 +460,8 @@ int test4_1467()
 
 one   sink_4_1567(               A&);  // { dg-message "candidates" }
 five  sink_4_1567(               A&&);  // { dg-message "note" }
-six   sink_4_1567(const          A&&);  // { dg-message "note" }
-seven sink_4_1567(volatile       A&&);  // { dg-message "note" }
+six   sink_4_1567(const          A&&);  // { dg-message "" }
+seven sink_4_1567(volatile       A&&);  // { dg-message "" }
 
 int test4_1567()
 {
@@ -354,15 +469,51 @@ int test4_1567()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_1567(ca);	       // { dg-error "lvalue" }
+    sink_4_1567(va);	       // { dg-error "lvalue" }
     sink_4_1567(cva);          // { dg-error "no match" }
     sink_4_1567(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_4_1568(               A&);
+five  sink_4_1568(               A&&);
+six   sink_4_1568(const          A&&); // { dg-message "" }
+eight sink_4_1568(const volatile A&&); // { dg-message "" }
+
+int test4_1568()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1568(ca);		// { dg-error "lvalue" }
+    sink_4_1568(va);		// { dg-error "lvalue" }
+    sink_4_1568(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+one   sink_4_1578(               A&);
+five  sink_4_1578(               A&&);
+seven sink_4_1578(volatile       A&&); // { dg-message "" }
+eight sink_4_1578(const volatile A&&); // { dg-message "" }
+
+int test4_1578()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_1578(ca);		// { dg-error "lvalue" }
+    sink_4_1578(va);		// { dg-error "lvalue" }
+    sink_4_1578(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_4_1678(               A&);
-six   sink_4_1678(const          A&&);  // { dg-message "candidates" }
-seven sink_4_1678(volatile       A&&);  // { dg-message "note" }
-eight sink_4_1678(const volatile A&&);  // { dg-message "note" }
+six   sink_4_1678(const          A&&);  // { dg-message "" }
+seven sink_4_1678(volatile       A&&);  // { dg-message "" }
+eight sink_4_1678(const volatile A&&);  // { dg-message "" }
 
 int test4_1678()
 {
@@ -370,6 +521,9 @@ int test4_1678()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_1678(ca);		// { dg-error "lvalue" }
+    sink_4_1678(va);		// { dg-error "lvalue" }
+    sink_4_1678(cva);		// { dg-error "lvalue" }
     sink_4_1678(source());  // { dg-error "ambiguous" }
     return 0;
 }
@@ -477,7 +631,7 @@ int test4_2357()
 two   sink_4_2358(const          A&);  // { dg-message "candidates" }
 three sink_4_2358(volatile       A&);  // { dg-message "note" }
 five  sink_4_2358(               A&&);  // { dg-message "note" }
-eight sink_4_2358(const volatile A&&);  // { dg-message "note" }
+eight sink_4_2358(const volatile A&&);  // { dg-message "" }
 
 int test4_2358()
 {
@@ -486,6 +640,7 @@ int test4_2358()
           volatile A va;
     const volatile A cva = a;
     sink_4_2358(a);  // { dg-error "ambiguous" }
+    sink_4_2358(cva); // { dg-error "lvalue" }
     return 0;
 }
 
@@ -510,7 +665,7 @@ int test4_2367()
 two   sink_4_2368(const          A&);  // { dg-message "candidates" }
 three sink_4_2368(volatile       A&);  // { dg-message "note" }
 six   sink_4_2368(const          A&&);  // { dg-message "note" }
-eight sink_4_2368(const volatile A&&);  // { dg-message "note" }
+eight sink_4_2368(const volatile A&&);  // { dg-message "" }
 
 int test4_2368()
 {
@@ -519,13 +674,14 @@ int test4_2368()
           volatile A va;
     const volatile A cva = a;
     sink_4_2368(a);  // { dg-error "ambiguous" }
+    sink_4_2368(cva); // { dg-error "lvalue" }
     return 0;
 }
 
 two   sink_4_2378(const          A&);  // { dg-message "candidates" }
 three sink_4_2378(volatile       A&);  // { dg-message "note" }
 seven sink_4_2378(volatile       A&&);  // { dg-message "note" }
-eight sink_4_2378(const volatile A&&);  // { dg-message "note" }
+eight sink_4_2378(const volatile A&&);  // { dg-message "" }
 
 int test4_2378()
 {
@@ -534,6 +690,7 @@ int test4_2378()
           volatile A va;
     const volatile A cva = a;
     sink_4_2378(a);  // { dg-error "ambiguous" }
+    sink_4_2378(cva); // { dg-error "lvalue" }
     return 0;
 }
 
@@ -587,7 +744,7 @@ int test4_2467()
 two   sink_4_2567(const          A&);  // { dg-message "candidates" }
 five  sink_4_2567(               A&&);  // { dg-message "note" }
 six   sink_4_2567(const          A&&);  // { dg-message "note" }
-seven sink_4_2567(volatile       A&&);  // { dg-message "note" }
+seven sink_4_2567(volatile       A&&);  // { dg-message "" }
 
 int test4_2567()
 {
@@ -595,15 +752,48 @@ int test4_2567()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_2567(va);		// { dg-error "lvalue" }
     sink_4_2567(cva);          // { dg-error "no match" }
     sink_4_2567(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+two   sink_4_2568(const          A&);
+five  sink_4_2568(               A&&);
+six   sink_4_2568(const          A&&);
+eight sink_4_2568(const volatile A&&); // { dg-message "" }
+
+int test4_2568()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_2568(va); // { dg-error "lvalue" }
+    sink_4_2568(cva); // { dg-error "lvalue" }
+    return 0;
+}
+
+two   sink_4_2578(const          A&);
+five  sink_4_2578(               A&&);
+seven sink_4_2578(volatile       A&&); // { dg-message "" }
+eight sink_4_2578(const volatile A&&); // { dg-message "" }
+
+int test4_2578()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_2578(va); // { dg-error "lvalue" }
+    sink_4_2578(cva); // { dg-error "lvalue" }
+    return 0;
+}
+
 two   sink_4_2678(const          A&);  // { dg-message "candidates" }
 six   sink_4_2678(const          A&&);  // { dg-message "note" }
-seven sink_4_2678(volatile       A&&);  // { dg-message "note" }
-eight sink_4_2678(const volatile A&&);  // { dg-message "note" }
+seven sink_4_2678(volatile       A&&);  // { dg-message "" }
+eight sink_4_2678(const volatile A&&);  // { dg-message "" }
 
 int test4_2678()
 {
@@ -611,6 +801,8 @@ int test4_2678()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_2678(va); // { dg-error "lvalue" }
+    sink_4_2678(cva); // { dg-error "lvalue" }
     sink_4_2678(source());  // { dg-error "ambiguous" }
     return 0;
 }
@@ -665,7 +857,7 @@ int test4_3467()
 
 three sink_4_3567(volatile       A&);  // { dg-message "candidates" }
 five  sink_4_3567(               A&&);  // { dg-message "note" }
-six   sink_4_3567(const          A&&);  // { dg-message "note" }
+six   sink_4_3567(const          A&&);  // { dg-message "" }
 seven sink_4_3567(volatile       A&&);  // { dg-message "note" }
 
 int test4_3567()
@@ -674,15 +866,48 @@ int test4_3567()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_3567(ca);		// { dg-error "lvalue" }
     sink_4_3567(cva);          // { dg-error "no match" }
     sink_4_3567(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+three sink_4_3568(volatile       A&);
+five  sink_4_3568(               A&&);
+six   sink_4_3568(const          A&&); // { dg-message "" }
+eight sink_4_3568(const volatile A&&); // { dg-message "" }
+
+int test4_3568()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_3568(ca); // { dg-error "lvalue" }
+    sink_4_3568(cva); // { dg-error "lvalue" }
+    return 0;
+}
+
+three sink_4_3578(volatile       A&);
+five  sink_4_3578(               A&&);
+seven sink_4_3578(volatile       A&&);
+eight sink_4_3578(const volatile A&&); // { dg-message "" }
+
+int test4_3578()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_3578(ca); // { dg-error "lvalue" }
+    sink_4_3578(cva); // { dg-error "lvalue" }
+    return 0;
+}
+
 three sink_4_3678(volatile       A&);
-six   sink_4_3678(const          A&&);  // { dg-message "candidates" }
+six   sink_4_3678(const          A&&);  // { dg-message "" }
 seven sink_4_3678(volatile       A&&);  // { dg-message "note" }
-eight sink_4_3678(const volatile A&&);  // { dg-message "note" }
+eight sink_4_3678(const volatile A&&);  // { dg-message "" }
 
 int test4_3678()
 {
@@ -690,6 +915,8 @@ int test4_3678()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_4_3678(ca);		// { dg-error "lvalue" }
+    sink_4_3678(cva);		// { dg-error "lvalue" }
     sink_4_3678(source());  // { dg-error "ambiguous" }
     return 0;
 }
@@ -724,6 +951,24 @@ int test4_4678()
     return 0;
 }
 
+five  sink_4_5678(               A&&); // { dg-message "" }
+six   sink_4_5678(const          A&&); // { dg-message "" }
+seven sink_4_5678(volatile       A&&); // { dg-message "" }
+eight sink_4_5678(const volatile A&&); // { dg-message "" }
+
+int test4_5678()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_4_5678(a);		// { dg-error "lvalue" }
+    sink_4_5678(ca);		// { dg-error "lvalue" }
+    sink_4_5678(va);		// { dg-error "lvalue" }
+    sink_4_5678(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 int main()
 {
     return test4_1235() + test4_1236() + test4_1237() + test4_1256() + test4_1257() +
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv4p.C b/gcc/testsuite/g++.dg/cpp0x/rv4p.C
index a486e75..03ad973 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv4p.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv4p.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -122,7 +122,6 @@ int test4_1238()
     sa<sizeof(sink_4_1238(a))           == 1> t1;
     sa<sizeof(sink_4_1238(ca))          == 2> t2;
     sa<sizeof(sink_4_1238(va))          == 3> t3;
-    sa<sizeof(sink_4_1238(cva))         == 8> t4;
     sa<sizeof(sink_4_1238(source()))    == 8> t5;
     sa<sizeof(sink_4_1238(c_source()))  == 8> t6;
     sa<sizeof(sink_4_1238(v_source()))  == 8> t7;
@@ -244,7 +243,6 @@ int test4_1257()
     const volatile A cva = a;
     sa<sizeof(sink_4_1257(a))           == 1> t1;
     sa<sizeof(sink_4_1257(ca))          == 2> t2;
-    sa<sizeof(sink_4_1257(va))          == 7> t3;
     sa<sizeof(sink_4_1257(source()))    == 5> t5;
     sa<sizeof(sink_4_1257(c_source()))  == 2> t6;
     sa<sizeof(sink_4_1257(v_source()))  == 7> t7;
@@ -264,8 +262,6 @@ int test4_1258()
     const volatile A cva = a;
     sa<sizeof(sink_4_1258(a))           == 1> t1;
     sa<sizeof(sink_4_1258(ca))          == 2> t2;
-    sa<sizeof(sink_4_1258(va))          == 8> t3;
-    sa<sizeof(sink_4_1258(cva))         == 8> t4;
     sa<sizeof(sink_4_1258(source()))    == 5> t5;
     sa<sizeof(sink_4_1258(c_source()))  == 8> t6;
     sa<sizeof(sink_4_1258(v_source()))  == 8> t7;
@@ -286,7 +282,6 @@ int test4_1267()
     const volatile A cva = a;
     sa<sizeof(sink_4_1267(a))           == 1> t1;
     sa<sizeof(sink_4_1267(ca))          == 2> t2;
-    sa<sizeof(sink_4_1267(va))          == 7> t3;
     sa<sizeof(sink_4_1267(c_source()))  == 6> t6;
     sa<sizeof(sink_4_1267(v_source()))  == 7> t7;
     return 0;
@@ -305,8 +300,6 @@ int test4_1268()
     const volatile A cva = a;
     sa<sizeof(sink_4_1268(a))           == 1> t1;
     sa<sizeof(sink_4_1268(ca))          == 2> t2;
-    sa<sizeof(sink_4_1268(va))          == 8> t3;
-    sa<sizeof(sink_4_1268(cva))         == 8> t4;
     sa<sizeof(sink_4_1268(source()))    == 6> t5;
     sa<sizeof(sink_4_1268(c_source()))  == 6> t6;
     sa<sizeof(sink_4_1268(v_source()))  == 8> t7;
@@ -327,8 +320,6 @@ int test4_1278()
     const volatile A cva = a;
     sa<sizeof(sink_4_1278(a))           == 1> t1;
     sa<sizeof(sink_4_1278(ca))          == 2> t2;
-    sa<sizeof(sink_4_1278(va))          == 7> t3;
-    sa<sizeof(sink_4_1278(cva))         == 8> t4;
     sa<sizeof(sink_4_1278(source()))    == 7> t5;
     sa<sizeof(sink_4_1278(c_source()))  == 8> t6;
     sa<sizeof(sink_4_1278(v_source()))  == 7> t7;
@@ -429,7 +420,6 @@ int test4_1356()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1356(a))           == 1> t1;
-    sa<sizeof(sink_4_1356(ca))          == 6> t2;
     sa<sizeof(sink_4_1356(va))          == 3> t3;
     sa<sizeof(sink_4_1356(source()))    == 5> t5;
     sa<sizeof(sink_4_1356(c_source()))  == 6> t6;
@@ -466,9 +456,7 @@ int test4_1358()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1358(a))           == 1> t1;
-    sa<sizeof(sink_4_1358(ca))          == 8> t2;
     sa<sizeof(sink_4_1358(va))          == 3> t3;
-    sa<sizeof(sink_4_1358(cva))         == 8> t4;
     sa<sizeof(sink_4_1358(source()))    == 5> t5;
     sa<sizeof(sink_4_1358(c_source()))  == 8> t6;
     sa<sizeof(sink_4_1358(v_source()))  == 8> t7;
@@ -488,7 +476,6 @@ int test4_1367()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1367(a))           == 1> t1;
-    sa<sizeof(sink_4_1367(ca))          == 6> t2;
     sa<sizeof(sink_4_1367(va))          == 3> t3;
     sa<sizeof(sink_4_1367(c_source()))  == 6> t6;
     sa<sizeof(sink_4_1367(v_source()))  == 7> t7;
@@ -507,9 +494,7 @@ int test4_1368()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1368(a))           == 1> t1;
-    sa<sizeof(sink_4_1368(ca))          == 6> t2;
     sa<sizeof(sink_4_1368(va))          == 3> t3;
-    sa<sizeof(sink_4_1368(cva))         == 8> t4;
     sa<sizeof(sink_4_1368(source()))    == 6> t5;
     sa<sizeof(sink_4_1368(c_source()))  == 6> t6;
     sa<sizeof(sink_4_1368(v_source()))  == 8> t7;
@@ -529,9 +514,7 @@ int test4_1378()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1378(a))           == 1> t1;
-    sa<sizeof(sink_4_1378(ca))          == 8> t2;
     sa<sizeof(sink_4_1378(va))          == 3> t3;
-    sa<sizeof(sink_4_1378(cva))         == 8> t4;
     sa<sizeof(sink_4_1378(source()))    == 7> t5;
     sa<sizeof(sink_4_1378(c_source()))  == 8> t6;
     sa<sizeof(sink_4_1378(v_source()))  == 7> t7;
@@ -677,8 +660,6 @@ int test4_1567()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1567(a))           == 1> t1;
-    sa<sizeof(sink_4_1567(ca))          == 6> t2;
-    sa<sizeof(sink_4_1567(va))          == 7> t3;
     sa<sizeof(sink_4_1567(source()))    == 5> t5;
     sa<sizeof(sink_4_1567(c_source()))  == 6> t6;
     sa<sizeof(sink_4_1567(v_source()))  == 7> t7;
@@ -697,9 +678,6 @@ int test4_1568()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1568(a))           == 1> t1;
-    sa<sizeof(sink_4_1568(ca))          == 6> t2;
-    sa<sizeof(sink_4_1568(va))          == 8> t3;
-    sa<sizeof(sink_4_1568(cva))         == 8> t4;
     sa<sizeof(sink_4_1568(source()))    == 5> t5;
     sa<sizeof(sink_4_1568(c_source()))  == 6> t6;
     sa<sizeof(sink_4_1568(v_source()))  == 8> t7;
@@ -719,9 +697,6 @@ int test4_1578()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1578(a))           == 1> t1;
-    sa<sizeof(sink_4_1578(ca))          == 8> t2;
-    sa<sizeof(sink_4_1578(va))          == 7> t3;
-    sa<sizeof(sink_4_1578(cva))         == 8> t4;
     sa<sizeof(sink_4_1578(source()))    == 5> t5;
     sa<sizeof(sink_4_1578(c_source()))  == 8> t6;
     sa<sizeof(sink_4_1578(v_source()))  == 7> t7;
@@ -741,9 +716,6 @@ int test4_1678()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_1678(a))           == 1> t1;
-    sa<sizeof(sink_4_1678(ca))          == 6> t2;
-    sa<sizeof(sink_4_1678(va))          == 7> t3;
-    sa<sizeof(sink_4_1678(cva))         == 8> t4;
     sa<sizeof(sink_4_1678(c_source()))  == 6> t6;
     sa<sizeof(sink_4_1678(v_source()))  == 7> t7;
     sa<sizeof(sink_4_1678(cv_source())) == 8> t8;
@@ -879,7 +851,6 @@ int test4_2358()
     const volatile A cva = a;
     sa<sizeof(sink_4_2358(ca))          == 2> t2;
     sa<sizeof(sink_4_2358(va))          == 3> t3;
-    sa<sizeof(sink_4_2358(cva))         == 8> t4;
     sa<sizeof(sink_4_2358(source()))    == 5> t5;
     sa<sizeof(sink_4_2358(c_source()))  == 8> t6;
     sa<sizeof(sink_4_2358(v_source()))  == 8> t7;
@@ -918,7 +889,6 @@ int test4_2368()
     const volatile A cva = a;
     sa<sizeof(sink_4_2368(ca))          == 2> t2;
     sa<sizeof(sink_4_2368(va))          == 3> t3;
-    sa<sizeof(sink_4_2368(cva))         == 8> t4;
     sa<sizeof(sink_4_2368(source()))    == 6> t5;
     sa<sizeof(sink_4_2368(c_source()))  == 6> t6;
     sa<sizeof(sink_4_2368(v_source()))  == 8> t7;
@@ -939,7 +909,6 @@ int test4_2378()
     const volatile A cva = a;
     sa<sizeof(sink_4_2378(ca))          == 2> t2;
     sa<sizeof(sink_4_2378(va))          == 3> t3;
-    sa<sizeof(sink_4_2378(cva))         == 8> t4;
     sa<sizeof(sink_4_2378(source()))    == 7> t5;
     sa<sizeof(sink_4_2378(c_source()))  == 8> t6;
     sa<sizeof(sink_4_2378(v_source()))  == 7> t7;
@@ -1087,7 +1056,6 @@ int test4_2567()
     const volatile A cva = a;
     sa<sizeof(sink_4_2567(a))           == 2> t1;
     sa<sizeof(sink_4_2567(ca))          == 2> t2;
-    sa<sizeof(sink_4_2567(va))          == 7> t3;
     sa<sizeof(sink_4_2567(source()))    == 5> t5;
     sa<sizeof(sink_4_2567(c_source()))  == 6> t6;
     sa<sizeof(sink_4_2567(v_source()))  == 7> t7;
@@ -1107,8 +1075,6 @@ int test4_2568()
     const volatile A cva = a;
     sa<sizeof(sink_4_2568(a))           == 2> t1;
     sa<sizeof(sink_4_2568(ca))          == 2> t2;
-    sa<sizeof(sink_4_2568(va))          == 8> t3;
-    sa<sizeof(sink_4_2568(cva))         == 8> t4;
     sa<sizeof(sink_4_2568(source()))    == 5> t5;
     sa<sizeof(sink_4_2568(c_source()))  == 6> t6;
     sa<sizeof(sink_4_2568(v_source()))  == 8> t7;
@@ -1129,8 +1095,6 @@ int test4_2578()
     const volatile A cva = a;
     sa<sizeof(sink_4_2578(a))           == 2> t1;
     sa<sizeof(sink_4_2578(ca))          == 2> t2;
-    sa<sizeof(sink_4_2578(va))          == 7> t3;
-    sa<sizeof(sink_4_2578(cva))         == 8> t4;
     sa<sizeof(sink_4_2578(source()))    == 5> t5;
     sa<sizeof(sink_4_2578(c_source()))  == 8> t6;
     sa<sizeof(sink_4_2578(v_source()))  == 7> t7;
@@ -1151,8 +1115,6 @@ int test4_2678()
     const volatile A cva = a;
     sa<sizeof(sink_4_2678(a))           == 2> t1;
     sa<sizeof(sink_4_2678(ca))          == 2> t2;
-    sa<sizeof(sink_4_2678(va))          == 7> t3;
-    sa<sizeof(sink_4_2678(cva))         == 8> t4;
     sa<sizeof(sink_4_2678(c_source()))  == 6> t6;
     sa<sizeof(sink_4_2678(v_source()))  == 7> t7;
     sa<sizeof(sink_4_2678(cv_source())) == 8> t8;
@@ -1297,7 +1259,6 @@ int test4_3567()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_3567(a))           == 3> t1;
-    sa<sizeof(sink_4_3567(ca))          == 6> t2;
     sa<sizeof(sink_4_3567(va))          == 3> t3;
     sa<sizeof(sink_4_3567(source()))    == 5> t5;
     sa<sizeof(sink_4_3567(c_source()))  == 6> t6;
@@ -1317,9 +1278,7 @@ int test4_3568()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_3568(a))           == 3> t1;
-    sa<sizeof(sink_4_3568(ca))          == 6> t2;
     sa<sizeof(sink_4_3568(va))          == 3> t3;
-    sa<sizeof(sink_4_3568(cva))         == 8> t4;
     sa<sizeof(sink_4_3568(source()))    == 5> t5;
     sa<sizeof(sink_4_3568(c_source()))  == 6> t6;
     sa<sizeof(sink_4_3568(v_source()))  == 8> t7;
@@ -1339,9 +1298,7 @@ int test4_3578()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_3578(a))           == 3> t1;
-    sa<sizeof(sink_4_3578(ca))          == 8> t2;
     sa<sizeof(sink_4_3578(va))          == 3> t3;
-    sa<sizeof(sink_4_3578(cva))         == 8> t4;
     sa<sizeof(sink_4_3578(source()))    == 5> t5;
     sa<sizeof(sink_4_3578(c_source()))  == 8> t6;
     sa<sizeof(sink_4_3578(v_source()))  == 7> t7;
@@ -1361,9 +1318,7 @@ int test4_3678()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_4_3678(a))           == 3> t1;
-    sa<sizeof(sink_4_3678(ca))          == 6> t2;
     sa<sizeof(sink_4_3678(va))          == 3> t3;
-    sa<sizeof(sink_4_3678(cva))         == 8> t4;
     sa<sizeof(sink_4_3678(c_source()))  == 6> t6;
     sa<sizeof(sink_4_3678(v_source()))  == 7> t7;
     sa<sizeof(sink_4_3678(cv_source())) == 8> t8;
@@ -1467,10 +1422,6 @@ int test4_5678()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
-    sa<sizeof(sink_4_5678(a))           == 5> t1;
-    sa<sizeof(sink_4_5678(ca))          == 6> t2;
-    sa<sizeof(sink_4_5678(va))          == 7> t3;
-    sa<sizeof(sink_4_5678(cva))         == 8> t4;
     sa<sizeof(sink_4_5678(source()))    == 5> t5;
     sa<sizeof(sink_4_5678(c_source()))  == 6> t6;
     sa<sizeof(sink_4_5678(v_source()))  == 7> t7;
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv5n.C b/gcc/testsuite/g++.dg/cpp0x/rv5n.C
index 14128b2..c31a30b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv5n.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv5n.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -115,6 +115,22 @@ int test5_12357()
     return 0;
 }
 
+one   sink_5_12358(               A&);
+two   sink_5_12358(const          A&);
+three sink_5_12358(volatile       A&);
+five  sink_5_12358(               A&&);
+eight sink_5_12358(const volatile A&&); // { dg-message "" }
+
+int test5_12358()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_12358(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_5_12367(               A&);  // { dg-message "candidates" }
 two   sink_5_12367(const          A&);  // { dg-message "note" }
 three sink_5_12367(volatile       A&);  // { dg-message "note" }
@@ -133,6 +149,38 @@ int test5_12367()
     return 0;
 }
 
+one   sink_5_12368(               A&);
+two   sink_5_12368(const          A&);
+three sink_5_12368(volatile       A&);
+six   sink_5_12368(const          A&&);
+eight sink_5_12368(const volatile A&&); // { dg-message "" }
+
+int test5_12368()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_12368(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+one   sink_5_12378(               A&);
+two   sink_5_12378(const          A&);
+three sink_5_12378(volatile       A&);
+seven sink_5_12378(volatile       A&&);
+eight sink_5_12378(const volatile A&&); // { dg-message "" }
+
+int test5_12378()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_12378(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_5_12456(               A&);  // { dg-message "candidates" }
 two   sink_5_12456(const          A&);  // { dg-message "note" }
 four  sink_5_12456(const volatile A&);  // { dg-message "note" }
@@ -187,7 +235,7 @@ one   sink_5_12567(               A&);  // { dg-message "candidates" }
 two   sink_5_12567(const          A&);  // { dg-message "note" }
 five  sink_5_12567(               A&&);  // { dg-message "note" }
 six   sink_5_12567(const          A&&);  // { dg-message "note" }
-seven sink_5_12567(volatile       A&&);  // { dg-message "note" }
+seven sink_5_12567(volatile       A&&);  // { dg-message "" }
 
 int test5_12567()
 {
@@ -195,16 +243,51 @@ int test5_12567()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_5_12567(va);		// { dg-error "lvalue" }
     sink_5_12567(cva);          // { dg-error "no match" }
     sink_5_12567(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_5_12568(               A&);
+two   sink_5_12568(const          A&);
+five  sink_5_12568(               A&&);
+six   sink_5_12568(const          A&&);
+eight sink_5_12568(const volatile A&&); // { dg-message "" }
+
+int test5_12568()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_12568(va);		// { dg-error "lvalue" }
+    sink_5_12568(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+one   sink_5_12578(               A&);
+two   sink_5_12578(const          A&);
+five  sink_5_12578(               A&&);
+seven sink_5_12578(volatile       A&&); // { dg-message "" }
+eight sink_5_12578(const volatile A&&); // { dg-message "" }
+
+int test5_12578()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_12578(va);		// { dg-error "lvalue" }
+    sink_5_12578(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_5_12678(               A&);
 two   sink_5_12678(const          A&);  // { dg-message "candidates" }
 six   sink_5_12678(const          A&&);  // { dg-message "note" }
-seven sink_5_12678(volatile       A&&);  // { dg-message "note" }
-eight sink_5_12678(const volatile A&&);  // { dg-message "note" }
+seven sink_5_12678(volatile       A&&);  // { dg-message "" }
+eight sink_5_12678(const volatile A&&);  // { dg-message "" }
 
 int test5_12678()
 {
@@ -212,6 +295,8 @@ int test5_12678()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_5_12678(va);		// { dg-error "lvalue" }
+    sink_5_12678(cva);		// { dg-error "lvalue" }
     sink_5_12678(source());  // { dg-error "ambiguous" }
     return 0;
 }
@@ -270,7 +355,7 @@ int test5_13467()
 one   sink_5_13567(               A&);  // { dg-message "candidates" }
 three sink_5_13567(volatile       A&);  // { dg-message "note" }
 five  sink_5_13567(               A&&);  // { dg-message "note" }
-six   sink_5_13567(const          A&&);  // { dg-message "note" }
+six   sink_5_13567(const          A&&);  // { dg-message "" }
 seven sink_5_13567(volatile       A&&);  // { dg-message "note" }
 
 int test5_13567()
@@ -279,16 +364,51 @@ int test5_13567()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_5_13567(ca);		// { dg-error "lvalue" }
     sink_5_13567(cva);          // { dg-error "no match" }
     sink_5_13567(cv_source());  // { dg-error "no match" }
     return 0;
 }
 
+one   sink_5_13568(               A&);
+three sink_5_13568(volatile       A&);
+five  sink_5_13568(               A&&);
+six   sink_5_13568(const          A&&); // { dg-message "" }
+eight sink_5_13568(const volatile A&&); // { dg-message "" }
+
+int test5_13568()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_13568(ca);		// { dg-error "lvalue" }
+    sink_5_13568(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
+one   sink_5_13578(               A&);
+three sink_5_13578(volatile       A&);
+five  sink_5_13578(               A&&);
+seven sink_5_13578(volatile       A&&);
+eight sink_5_13578(const volatile A&&); // { dg-message "" }
+
+int test5_13578()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_13578(ca);		// { dg-error "lvalue" }
+    sink_5_13578(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_5_13678(               A&);
 three sink_5_13678(volatile       A&);
-six   sink_5_13678(const          A&&);  // { dg-message "candidates" }
+six   sink_5_13678(const          A&&);  // { dg-message "" }
 seven sink_5_13678(volatile       A&&);  // { dg-message "note" }
-eight sink_5_13678(const volatile A&&);  // { dg-message "note" }
+eight sink_5_13678(const volatile A&&);  // { dg-message "" }
 
 int test5_13678()
 {
@@ -296,6 +416,8 @@ int test5_13678()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_5_13678(ca);		// { dg-error "lvalue" }
+    sink_5_13678(cva);		// { dg-error "lvalue" }
     sink_5_13678(source());  // { dg-error "ambiguous" }
     return 0;
 }
@@ -332,6 +454,24 @@ int test5_14678()
     return 0;
 }
 
+one   sink_5_15678(               A&);
+five  sink_5_15678(               A&&);
+six   sink_5_15678(const          A&&); // { dg-message "" }
+seven sink_5_15678(volatile       A&&); // { dg-message "" }
+eight sink_5_15678(const volatile A&&); // { dg-message "" }
+
+int test5_15678()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_15678(ca);		// { dg-error "lvalue" }
+    sink_5_15678(va);		// { dg-error "lvalue" }
+    sink_5_15678(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 two   sink_5_23456(const          A&);  // { dg-message "candidates" }
 three sink_5_23456(volatile       A&);  // { dg-message "note" }
 four  sink_5_23456(const volatile A&);  // { dg-message "note" }
@@ -455,7 +595,7 @@ two   sink_5_23568(const          A&);  // { dg-message "candidates" }
 three sink_5_23568(volatile       A&);  // { dg-message "note" }
 five  sink_5_23568(               A&&);  // { dg-message "note" }
 six   sink_5_23568(const          A&&);  // { dg-message "note" }
-eight sink_5_23568(const volatile A&&);  // { dg-message "note" }
+eight sink_5_23568(const volatile A&&);  // { dg-message "" }
 
 int test5_23568()
 {
@@ -463,6 +603,7 @@ int test5_23568()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_5_23568(cva); // { dg-error "lvalue" }
     sink_5_23568(a);  // { dg-error "ambiguous" }
     return 0;
 }
@@ -471,7 +612,7 @@ two   sink_5_23578(const          A&);  // { dg-message "candidates" }
 three sink_5_23578(volatile       A&);  // { dg-message "note" }
 five  sink_5_23578(               A&&);  // { dg-message "note" }
 seven sink_5_23578(volatile       A&&);  // { dg-message "note" }
-eight sink_5_23578(const volatile A&&);  // { dg-message "note" }
+eight sink_5_23578(const volatile A&&);  // { dg-message "" }
 
 int test5_23578()
 {
@@ -479,6 +620,7 @@ int test5_23578()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_5_23578(cva); // { dg-error "lvalue" }
     sink_5_23578(a);  // { dg-error "ambiguous" }
     return 0;
 }
@@ -487,7 +629,7 @@ two   sink_5_23678(const          A&);  // { dg-message "candidates" }
 three sink_5_23678(volatile       A&);  // { dg-message "note" }
 six   sink_5_23678(const          A&&);  // { dg-message "note" }
 seven sink_5_23678(volatile       A&&);  // { dg-message "note" }
-eight sink_5_23678(const volatile A&&);  // { dg-message "note" }
+eight sink_5_23678(const volatile A&&);  // { dg-message "" }
 
 int test5_23678()
 {
@@ -496,6 +638,7 @@ int test5_23678()
           volatile A va;
     const volatile A cva = a;
     sink_5_23678(a);         // { dg-error "ambiguous" }
+    sink_5_23678(cva);	     // { dg-error "lvalue" }
     sink_5_23678(source());  // { dg-error "ambiguous" }
     return 0;
 }
@@ -532,6 +675,23 @@ int test5_24678()
     return 0;
 }
 
+two   sink_5_25678(const          A&);
+five  sink_5_25678(               A&&);
+six   sink_5_25678(const          A&&);
+seven sink_5_25678(volatile       A&&); // { dg-message "" }
+eight sink_5_25678(const volatile A&&); // { dg-message "" }
+
+int test5_25678()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_25678(va);		// { dg-error "lvalue" }
+    sink_5_25678(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 three sink_5_34567(volatile       A&);  // { dg-message "candidates" }
 four  sink_5_34567(const volatile A&);  // { dg-message "note" }
 five  sink_5_34567(               A&&);  // { dg-message "note" }
@@ -564,6 +724,23 @@ int test5_34678()
     return 0;
 }
 
+three sink_5_35678(volatile       A&);
+five  sink_5_35678(               A&&);
+six   sink_5_35678(const          A&&); // { dg-message "" }
+seven sink_5_35678(volatile       A&&);
+eight sink_5_35678(const volatile A&&); // { dg-message "" }
+
+int test5_35678()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_5_35678(ca);		// { dg-error "lvalue" }
+    sink_5_35678(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 int main()
 {
     return test5_12356() + test5_12357() + test5_12367() + test5_12467() +
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv5p.C b/gcc/testsuite/g++.dg/cpp0x/rv5p.C
index a4d9167..7555867 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv5p.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv5p.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -173,7 +173,6 @@ int test5_12358()
     sa<sizeof(sink_5_12358(a))           == 1> t1;
     sa<sizeof(sink_5_12358(ca))          == 2> t2;
     sa<sizeof(sink_5_12358(va))          == 3> t3;
-    sa<sizeof(sink_5_12358(cva))         == 8> t4;
     sa<sizeof(sink_5_12358(source()))    == 5> t5;
     sa<sizeof(sink_5_12358(c_source()))  == 8> t6;
     sa<sizeof(sink_5_12358(v_source()))  == 8> t7;
@@ -216,7 +215,6 @@ int test5_12368()
     sa<sizeof(sink_5_12368(a))           == 1> t1;
     sa<sizeof(sink_5_12368(ca))          == 2> t2;
     sa<sizeof(sink_5_12368(va))          == 3> t3;
-    sa<sizeof(sink_5_12368(cva))         == 8> t4;
     sa<sizeof(sink_5_12368(source()))    == 6> t5;
     sa<sizeof(sink_5_12368(c_source()))  == 6> t6;
     sa<sizeof(sink_5_12368(v_source()))  == 8> t7;
@@ -239,7 +237,6 @@ int test5_12378()
     sa<sizeof(sink_5_12378(a))           == 1> t1;
     sa<sizeof(sink_5_12378(ca))          == 2> t2;
     sa<sizeof(sink_5_12378(va))          == 3> t3;
-    sa<sizeof(sink_5_12378(cva))         == 8> t4;
     sa<sizeof(sink_5_12378(source()))    == 7> t5;
     sa<sizeof(sink_5_12378(c_source()))  == 8> t6;
     sa<sizeof(sink_5_12378(v_source()))  == 7> t7;
@@ -394,7 +391,6 @@ int test5_12567()
     const volatile A cva = a;
     sa<sizeof(sink_5_12567(a))           == 1> t1;
     sa<sizeof(sink_5_12567(ca))          == 2> t2;
-    sa<sizeof(sink_5_12567(va))          == 7> t3;
     sa<sizeof(sink_5_12567(source()))    == 5> t5;
     sa<sizeof(sink_5_12567(c_source()))  == 6> t6;
     sa<sizeof(sink_5_12567(v_source()))  == 7> t7;
@@ -415,8 +411,6 @@ int test5_12568()
     const volatile A cva = a;
     sa<sizeof(sink_5_12568(a))           == 1> t1;
     sa<sizeof(sink_5_12568(ca))          == 2> t2;
-    sa<sizeof(sink_5_12568(va))          == 8> t3;
-    sa<sizeof(sink_5_12568(cva))         == 8> t4;
     sa<sizeof(sink_5_12568(source()))    == 5> t5;
     sa<sizeof(sink_5_12568(c_source()))  == 6> t6;
     sa<sizeof(sink_5_12568(v_source()))  == 8> t7;
@@ -438,8 +432,6 @@ int test5_12578()
     const volatile A cva = a;
     sa<sizeof(sink_5_12578(a))           == 1> t1;
     sa<sizeof(sink_5_12578(ca))          == 2> t2;
-    sa<sizeof(sink_5_12578(va))          == 7> t3;
-    sa<sizeof(sink_5_12578(cva))         == 8> t4;
     sa<sizeof(sink_5_12578(source()))    == 5> t5;
     sa<sizeof(sink_5_12578(c_source()))  == 8> t6;
     sa<sizeof(sink_5_12578(v_source()))  == 7> t7;
@@ -461,8 +453,6 @@ int test5_12678()
     const volatile A cva = a;
     sa<sizeof(sink_5_12678(a))           == 1> t1;
     sa<sizeof(sink_5_12678(ca))          == 2> t2;
-    sa<sizeof(sink_5_12678(va))          == 7> t3;
-    sa<sizeof(sink_5_12678(cva))         == 8> t4;
     sa<sizeof(sink_5_12678(c_source()))  == 6> t6;
     sa<sizeof(sink_5_12678(v_source()))  == 7> t7;
     sa<sizeof(sink_5_12678(cv_source())) == 8> t8;
@@ -614,7 +604,6 @@ int test5_13567()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_5_13567(a))           == 1> t1;
-    sa<sizeof(sink_5_13567(ca))          == 6> t2;
     sa<sizeof(sink_5_13567(va))          == 3> t3;
     sa<sizeof(sink_5_13567(source()))    == 5> t5;
     sa<sizeof(sink_5_13567(c_source()))  == 6> t6;
@@ -635,9 +624,7 @@ int test5_13568()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_5_13568(a))           == 1> t1;
-    sa<sizeof(sink_5_13568(ca))          == 6> t2;
     sa<sizeof(sink_5_13568(va))          == 3> t3;
-    sa<sizeof(sink_5_13568(cva))         == 8> t4;
     sa<sizeof(sink_5_13568(source()))    == 5> t5;
     sa<sizeof(sink_5_13568(c_source()))  == 6> t6;
     sa<sizeof(sink_5_13568(v_source()))  == 8> t7;
@@ -658,9 +645,7 @@ int test5_13578()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_5_13578(a))           == 1> t1;
-    sa<sizeof(sink_5_13578(ca))          == 8> t2;
     sa<sizeof(sink_5_13578(va))          == 3> t3;
-    sa<sizeof(sink_5_13578(cva))         == 8> t4;
     sa<sizeof(sink_5_13578(source()))    == 5> t5;
     sa<sizeof(sink_5_13578(c_source()))  == 8> t6;
     sa<sizeof(sink_5_13578(v_source()))  == 7> t7;
@@ -681,9 +666,7 @@ int test5_13678()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_5_13678(a))           == 1> t1;
-    sa<sizeof(sink_5_13678(ca))          == 6> t2;
     sa<sizeof(sink_5_13678(va))          == 3> t3;
-    sa<sizeof(sink_5_13678(cva))         == 8> t4;
     sa<sizeof(sink_5_13678(c_source()))  == 6> t6;
     sa<sizeof(sink_5_13678(v_source()))  == 7> t7;
     sa<sizeof(sink_5_13678(cv_source())) == 8> t8;
@@ -793,9 +776,6 @@ int test5_15678()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_5_15678(a))           == 1> t1;
-    sa<sizeof(sink_5_15678(ca))          == 6> t2;
-    sa<sizeof(sink_5_15678(va))          == 7> t3;
-    sa<sizeof(sink_5_15678(cva))         == 8> t4;
     sa<sizeof(sink_5_15678(source()))    == 5> t5;
     sa<sizeof(sink_5_15678(c_source()))  == 6> t6;
     sa<sizeof(sink_5_15678(v_source()))  == 7> t7;
@@ -964,7 +944,6 @@ int test5_23568()
     const volatile A cva = a;
     sa<sizeof(sink_5_23568(ca))          == 2> t2;
     sa<sizeof(sink_5_23568(va))          == 3> t3;
-    sa<sizeof(sink_5_23568(cva))         == 8> t4;
     sa<sizeof(sink_5_23568(source()))    == 5> t5;
     sa<sizeof(sink_5_23568(c_source()))  == 6> t6;
     sa<sizeof(sink_5_23568(v_source()))  == 8> t7;
@@ -986,7 +965,6 @@ int test5_23578()
     const volatile A cva = a;
     sa<sizeof(sink_5_23578(ca))          == 2> t2;
     sa<sizeof(sink_5_23578(va))          == 3> t3;
-    sa<sizeof(sink_5_23578(cva))         == 8> t4;
     sa<sizeof(sink_5_23578(source()))    == 5> t5;
     sa<sizeof(sink_5_23578(c_source()))  == 8> t6;
     sa<sizeof(sink_5_23578(v_source()))  == 7> t7;
@@ -1008,7 +986,6 @@ int test5_23678()
     const volatile A cva = a;
     sa<sizeof(sink_5_23678(ca))          == 2> t2;
     sa<sizeof(sink_5_23678(va))          == 3> t3;
-    sa<sizeof(sink_5_23678(cva))         == 8> t4;
     sa<sizeof(sink_5_23678(c_source()))  == 6> t6;
     sa<sizeof(sink_5_23678(v_source()))  == 7> t7;
     sa<sizeof(sink_5_23678(cv_source())) == 8> t8;
@@ -1119,8 +1096,6 @@ int test5_25678()
     const volatile A cva = a;
     sa<sizeof(sink_5_25678(a))           == 2> t1;
     sa<sizeof(sink_5_25678(ca))          == 2> t2;
-    sa<sizeof(sink_5_25678(va))          == 7> t3;
-    sa<sizeof(sink_5_25678(cva))         == 8> t4;
     sa<sizeof(sink_5_25678(source()))    == 5> t5;
     sa<sizeof(sink_5_25678(c_source()))  == 6> t6;
     sa<sizeof(sink_5_25678(v_source()))  == 7> t7;
@@ -1231,9 +1206,7 @@ int test5_35678()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_5_35678(a))           == 3> t1;
-    sa<sizeof(sink_5_35678(ca))          == 6> t2;
     sa<sizeof(sink_5_35678(va))          == 3> t3;
-    sa<sizeof(sink_5_35678(cva))         == 8> t4;
     sa<sizeof(sink_5_35678(source()))    == 5> t5;
     sa<sizeof(sink_5_35678(c_source()))  == 6> t6;
     sa<sizeof(sink_5_35678(v_source()))  == 7> t7;
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv6n.C b/gcc/testsuite/g++.dg/cpp0x/rv6n.C
index 040c0f6..2a2520c 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv6n.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv6n.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -70,7 +70,7 @@ three sink_6_235678(volatile       A&);  // { dg-message "note" }
 five  sink_6_235678(               A&&);  // { dg-message "note" }
 six   sink_6_235678(const          A&&);  // { dg-message "note" }
 seven sink_6_235678(volatile       A&&);  // { dg-message "note" }
-eight sink_6_235678(const volatile A&&);  // { dg-message "note" }
+eight sink_6_235678(const volatile A&&);  // { dg-message "" }
 
 int test6_235678()
 {
@@ -79,6 +79,7 @@ int test6_235678()
           volatile A va;
     const volatile A cva = a;
     sink_6_235678(a);  // { dg-error "ambiguous" }
+    sink_6_235678(cva);		// { dg-error "lvalue" }
     return 0;
 }
 
@@ -191,7 +192,7 @@ two   sink_6_123678(const          A&);  // { dg-message "candidates" }
 three sink_6_123678(volatile       A&);
 six   sink_6_123678(const          A&&);  // { dg-message "note" }
 seven sink_6_123678(volatile       A&&);  // { dg-message "note" }
-eight sink_6_123678(const volatile A&&);  // { dg-message "note" }
+eight sink_6_123678(const volatile A&&);  // { dg-message "" }
 
 int test6_123678()
 {
@@ -199,6 +200,7 @@ int test6_123678()
     const          A ca = a;
           volatile A va;
     const volatile A cva = a;
+    sink_6_123678(cva);		// { dg-error "lvalue" }
     sink_6_123678(source());  // { dg-error "ambiguous" }
     return 0;
 }
@@ -221,6 +223,40 @@ int test6_123567()
     return 0;
 }
 
+one   sink_6_123568(               A&);
+two   sink_6_123568(const          A&);
+three sink_6_123568(volatile       A&);
+five  sink_6_123568(               A&&);
+six   sink_6_123568(const          A&&);
+eight sink_6_123568(const volatile A&&); // { dg-message "" }
+
+int test6_123568()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_6_123568(cva); // { dg-error "lvalue" }
+    return 0;
+}
+
+one   sink_6_123578(               A&);
+two   sink_6_123578(const          A&);
+three sink_6_123578(volatile       A&);
+five  sink_6_123578(               A&&);
+seven sink_6_123578(volatile       A&&);
+eight sink_6_123578(const volatile A&&); // { dg-message "" }
+
+int test6_123578()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_6_123578(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_6_123467(               A&);  // { dg-message "candidates" }
 two   sink_6_123467(const          A&);  // { dg-message "note" }
 three sink_6_123467(volatile       A&);  // { dg-message "note" }
@@ -256,6 +292,24 @@ int test6_124567()
     return 0;
 }
 
+one   sink_6_125678(               A&);
+two   sink_6_125678(const          A&);
+five  sink_6_125678(               A&&);
+six   sink_6_125678(const          A&&);
+seven sink_6_125678(volatile       A&&); // { dg-message "" }
+eight sink_6_125678(const volatile A&&); // { dg-message "" }
+
+int test6_125678()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_6_125678(va);		// { dg-error "lvalue" }
+    sink_6_125678(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 one   sink_6_134567(               A&);  // { dg-message "candidates" }
 three sink_6_134567(volatile       A&);  // { dg-message "note" }
 four  sink_6_134567(const volatile A&);  // { dg-message "note" }
@@ -273,6 +327,24 @@ int test6_134567()
     return 0;
 }
 
+one   sink_6_135678(               A&);
+three sink_6_135678(volatile       A&);
+five  sink_6_135678(               A&&);
+six   sink_6_135678(const          A&&); // { dg-message "" }
+seven sink_6_135678(volatile       A&&);
+eight sink_6_135678(const volatile A&&); // { dg-message "" }
+
+int test6_135678()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_6_135678(ca);		// { dg-error "lvalue" }
+    sink_6_135678(cva);		// { dg-error "lvalue" }
+    return 0;
+}
+
 int main()
 {
     return test6_235678() + test6_234678() + test6_234578() + test6_234568() +
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv6p.C b/gcc/testsuite/g++.dg/cpp0x/rv6p.C
index a59958e..0e5352b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv6p.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv6p.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -207,7 +207,6 @@ int test6_123568()
     sa<sizeof(sink_6_123568(a))           == 1> t1;
     sa<sizeof(sink_6_123568(ca))          == 2> t2;
     sa<sizeof(sink_6_123568(va))          == 3> t3;
-    sa<sizeof(sink_6_123568(cva))         == 8> t4;
     sa<sizeof(sink_6_123568(source()))    == 5> t5;
     sa<sizeof(sink_6_123568(c_source()))  == 6> t6;
     sa<sizeof(sink_6_123568(v_source()))  == 8> t7;
@@ -231,7 +230,6 @@ int test6_123578()
     sa<sizeof(sink_6_123578(a))           == 1> t1;
     sa<sizeof(sink_6_123578(ca))          == 2> t2;
     sa<sizeof(sink_6_123578(va))          == 3> t3;
-    sa<sizeof(sink_6_123578(cva))         == 8> t4;
     sa<sizeof(sink_6_123578(source()))    == 5> t5;
     sa<sizeof(sink_6_123578(c_source()))  == 8> t6;
     sa<sizeof(sink_6_123578(v_source()))  == 7> t7;
@@ -255,7 +253,6 @@ int test6_123678()
     sa<sizeof(sink_6_123678(a))           == 1> t1;
     sa<sizeof(sink_6_123678(ca))          == 2> t2;
     sa<sizeof(sink_6_123678(va))          == 3> t3;
-    sa<sizeof(sink_6_123678(cva))         == 8> t4;
     sa<sizeof(sink_6_123678(c_source()))  == 6> t6;
     sa<sizeof(sink_6_123678(v_source()))  == 7> t7;
     sa<sizeof(sink_6_123678(cv_source())) == 8> t8;
@@ -371,8 +368,6 @@ int test6_125678()
     const volatile A cva = a;
     sa<sizeof(sink_6_125678(a))           == 1> t1;
     sa<sizeof(sink_6_125678(ca))          == 2> t2;
-    sa<sizeof(sink_6_125678(va))          == 7> t3;
-    sa<sizeof(sink_6_125678(cva))         == 8> t4;
     sa<sizeof(sink_6_125678(source()))    == 5> t5;
     sa<sizeof(sink_6_125678(c_source()))  == 6> t6;
     sa<sizeof(sink_6_125678(v_source()))  == 7> t7;
@@ -488,9 +483,7 @@ int test6_135678()
           volatile A va;
     const volatile A cva = a;
     sa<sizeof(sink_6_135678(a))           == 1> t1;
-    sa<sizeof(sink_6_135678(ca))          == 6> t2;
     sa<sizeof(sink_6_135678(va))          == 3> t3;
-    sa<sizeof(sink_6_135678(cva))         == 8> t4;
     sa<sizeof(sink_6_135678(source()))    == 5> t5;
     sa<sizeof(sink_6_135678(c_source()))  == 6> t6;
     sa<sizeof(sink_6_135678(v_source()))  == 7> t7;
@@ -627,7 +620,6 @@ int test6_235678()
     const volatile A cva = a;
     sa<sizeof(sink_6_235678(ca))          == 2> t2;
     sa<sizeof(sink_6_235678(va))          == 3> t3;
-    sa<sizeof(sink_6_235678(cva))         == 8> t4;
     sa<sizeof(sink_6_235678(source()))    == 5> t5;
     sa<sizeof(sink_6_235678(c_source()))  == 6> t6;
     sa<sizeof(sink_6_235678(v_source()))  == 7> t7;
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv7n.C b/gcc/testsuite/g++.dg/cpp0x/rv7n.C
index 9d81bd5..102730b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv7n.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv7n.C
@@ -48,6 +48,24 @@ int test7_1234567()
     return 0;
 }
 
+one   sink_7_1235678(               A&);
+two   sink_7_1235678(const          A&);
+three sink_7_1235678(volatile       A&);
+five  sink_7_1235678(               A&&);
+six   sink_7_1235678(const          A&&);
+seven sink_7_1235678(volatile       A&&);
+eight sink_7_1235678(const volatile A&&); // { dg-message "" }
+
+int test7_1235678()
+{
+                   A a;
+    const          A ca = a;
+          volatile A va;
+    const volatile A cva = a;
+    sink_7_1235678(cva);	// { dg-error "lvalue" }
+    return 0;
+}
+
 two   sink_7_2345678(const          A&);  // { dg-message "candidates" }
 three sink_7_2345678(volatile       A&);  // { dg-message "note" }
 four  sink_7_2345678(const volatile A&);  // { dg-message "note" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv7p.C b/gcc/testsuite/g++.dg/cpp0x/rv7p.C
index d3e1474..d25488f 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv7p.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv7p.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
@@ -145,7 +145,6 @@ int test7_1235678()
     sa<sizeof(sink_7_1235678(a))           == 1> t1;
     sa<sizeof(sink_7_1235678(ca))          == 2> t2;
     sa<sizeof(sink_7_1235678(va))          == 3> t3;
-    sa<sizeof(sink_7_1235678(cva))         == 8> t4;
     sa<sizeof(sink_7_1235678(source()))    == 5> t5;
     sa<sizeof(sink_7_1235678(c_source()))  == 6> t6;
     sa<sizeof(sink_7_1235678(v_source()))  == 7> t7;
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv8p.C b/gcc/testsuite/g++.dg/cpp0x/rv8p.C
index 95a72d5..cc7ff8a 100644
--- a/gcc/testsuite/g++.dg/cpp0x/rv8p.C
+++ b/gcc/testsuite/g++.dg/cpp0x/rv8p.C
@@ -1,6 +1,6 @@
 // I, Howard Hinnant, hereby place this code in the public domain.
 
-// Test overlaod resolution among referece types
+// Test overload resolution among reference types
 
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/template_deduction.C b/gcc/testsuite/g++.dg/cpp0x/template_deduction.C
index ee48fb3..c1eace6 100644
--- a/gcc/testsuite/g++.dg/cpp0x/template_deduction.C
+++ b/gcc/testsuite/g++.dg/cpp0x/template_deduction.C
@@ -35,7 +35,7 @@ test1(T&&)
 
 template <bool is_lvalue_ref, bool is_rvalue_ref, class T>
 void
-test2(const T&&)
+test2(const T&&)		// { dg-error "argument" }
 {
     sa<is_lvalue_reference<const T&&>::value == is_lvalue_ref> t1;
     sa<is_rvalue_reference<const T&&>::value == is_rvalue_ref> t2;
@@ -60,7 +60,7 @@ int main()
 {
     test1<true, false>(a);
     test1<false, true>(source());
-    test2<false, true>(a);
+    test2<false, true>(a);	// { dg-error "lvalue" }
     test2<false, true>(source());
     test3<false, true>(&a);
     test3<false, true>(sourcep());
diff --git a/gcc/testsuite/g++.dg/cpp0x/unnamed_refs.C b/gcc/testsuite/g++.dg/cpp0x/unnamed_refs.C
index 0631185..57d6359 100644
--- a/gcc/testsuite/g++.dg/cpp0x/unnamed_refs.C
+++ b/gcc/testsuite/g++.dg/cpp0x/unnamed_refs.C
@@ -16,7 +16,12 @@ struct A {};
 one foo(const A&) {return one();}
 two foo(A&&)      {return two();}
 
-A&& source() {static A a; return a;}
+template<typename _Tp>
+inline _Tp&&
+movel(_Tp& __t)
+{ return static_cast<_Tp&&>(__t); }
+
+A&& source() {static A a; return movel(a);}
 
 int test1()
 {
diff --git a/libstdc++-v3/testsuite/27_io/rvalue_streams.cc b/libstdc++-v3/testsuite/27_io/rvalue_streams.cc
new file mode 100644
index 0000000..b3cc630
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/rvalue_streams.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2008 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// { dg-do run }
+
+#include <sstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  int i = 1742;
+  // This usage isn't supported by the current draft.
+  // std::string result = (std::ostringstream() << i).str();
+  std::ostringstream() << i;
+  std::string result ("1742");
+  int i2;
+  std::istringstream(result) >> i2;
+  VERIFY (i == i2);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
2009-07-31  Jason Merrill  <jason@redhat.com>

	* include/bits/forward_list.h (splice_after): Use forward.
	(merge): Likewise.
	* include/bits/stl_iterator.h (move_iterator::operator*): Use move.
	(move_iterator::operator[]): Use move.
	* include/bits/stl_list.h (insert): Use move.
	* include/std/thread (_Callable constructor): Use forward.
	* include/std/tuple: Don't specify explicit template args to move.

	* testsuite/20_util/forward/requirements/explicit_instantiation.cc:
	Adjust signature.
	* testsuite/20_util/tuple/swap.cc: Swap takes lvalue reference.
	* testsuite/30_threads/shared_future/cons/copy.cc: Return rvalue
	reference.
	* testsuite/20_util/shared_ptr/assign/auto_ptr.cc,
	testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc,
	testsuite/20_util/shared_ptr/cons/auto_ptr.cc,
	testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc,
	testsuite/23_containers/forward_list/ext_pointer/operations/1.cc,
	testsuite/23_containers/forward_list/ext_pointer/operations/5.cc,
	testsuite/23_containers/forward_list/operations/1.cc,
	testsuite/23_containers/forward_list/operations/5.cc: Use move.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc,
	testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc,
	testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc,
	testsuite/23_containers/list/requirements/dr438/insert_neg.cc,
	testsuite/30_threads/thread/cons/assign_neg.cc: Adjust line numbers.

diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h
index 724d87b..5158f2d 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -1057,7 +1057,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       void
       splice_after(const_iterator __pos, forward_list&& __list,
                    const_iterator __it)
-      { this->splice_after(__pos, __list, __it, __it._M_next()); }
+      {
+	this->splice_after(__pos, std::forward<forward_list>(__list),
+			   __it, __it._M_next());
+      }
 
       /**
        *  @brief  Insert range from another %forward_list.
@@ -1146,7 +1149,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        */
       void
       merge(forward_list&& __list)
-      { this->merge(__list, std::less<_Tp>()); }
+      { this->merge(std::forward<forward_list>(__list), std::less<_Tp>()); }
 
       /**
        *  @brief  Merge sorted lists according to comparison function.
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 129552f..eb72900 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -913,7 +913,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       reference
       operator*() const
-      { return *_M_current; }
+      { return std::move(*_M_current); }
 
       pointer
       operator->() const
@@ -973,7 +973,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       reference
       operator[](difference_type __n) const
-      { return _M_current[__n]; }
+      { return std::move(_M_current[__n]); }
     };
 
   template<typename _IteratorL, typename _IteratorR>
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index f758bae..2a6e58f 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -1027,7 +1027,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       insert(iterator __position, size_type __n, const value_type& __x)
       {  
 	list __tmp(__n, __x, _M_get_Node_allocator());
-	splice(__position, __tmp);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+	  splice(__position, std::move(__tmp));
+#else
+	  splice(__position, __tmp);
+#endif
       }
 
       /**
@@ -1049,7 +1053,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
 	       _InputIterator __last)
         {
 	  list __tmp(__first, __last, _M_get_Node_allocator());
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+	  splice(__position, std::move(__tmp));
+#else
 	  splice(__position, __tmp);
+#endif
 	}
 
       /**
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index bf282cc..83b259d 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -126,7 +126,10 @@ namespace std
 
     template<typename _Callable>
       explicit thread(_Callable __f)
-      { _M_start_thread(_M_make_routine<_Callable>(__f)); }
+      {
+	_M_start_thread(_M_make_routine<_Callable>
+			(std::forward<_Callable>(__f)));
+      }
 
     template<typename _Callable, typename... _Args>
       thread(_Callable&& __f, _Args&&... __args)
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 8dc8dcf..18cd89b 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -164,7 +164,7 @@ namespace std
       : _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
 
       _Tuple_impl(_Tuple_impl&& __in)
-      : _Inherited(std::move<_Inherited&&>(__in._M_tail())),
+      : _Inherited(std::move(__in._M_tail())),
 	_Base(std::forward<_Head>(__in._M_head())) { }
 
       template<typename... _UElements>
@@ -173,8 +173,7 @@ namespace std
 
       template<typename... _UElements>
         _Tuple_impl(_Tuple_impl<_Idx, _UElements...>&& __in)
-	: _Inherited(std::move<typename _Tuple_impl<_Idx, _UElements...>::
-		     _Inherited&&>(__in._M_tail())),
+	: _Inherited(std::move(__in._M_tail())),
 	  _Base(std::forward<typename _Tuple_impl<_Idx, _UElements...>::
 		_Base>(__in._M_head())) { }
 
@@ -244,7 +243,7 @@ namespace std
       : _Inherited(static_cast<const _Inherited&>(__in)) { }
 
       tuple(tuple&& __in)
-      : _Inherited(std::move<_Inherited>(__in)) { }
+      : _Inherited(static_cast<_Inherited&&>(__in)) { }
 
       template<typename... _UElements>
         tuple(const tuple<_UElements...>& __in)
@@ -253,7 +252,7 @@ namespace std
 
       template<typename... _UElements>
         tuple(tuple<_UElements...>&& __in)
-	: _Inherited(std::move<_Tuple_impl<0, _UElements...> >(__in)) { }
+	: _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
 
       // XXX http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html
       template<typename... _UElements>
@@ -327,7 +326,7 @@ namespace std
       : _Inherited(static_cast<const _Inherited&>(__in)) { }
 
       tuple(tuple&& __in)
-      : _Inherited(std::move<_Inherited>(__in)) { }
+      : _Inherited(static_cast<_Inherited&&>(__in)) { }
 
       template<typename _U1, typename _U2>
         tuple(const tuple<_U1, _U2>& __in)
@@ -335,7 +334,7 @@ namespace std
 
       template<typename _U1, typename _U2>
         tuple(tuple<_U1, _U2>&& __in)
-	: _Inherited(std::move<_Tuple_impl<0, _U1, _U2> >(__in)) { }
+	: _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { }
 
       template<typename _U1, typename _U2>
         tuple(const pair<_U1, _U2>& __in)
diff --git a/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc
index 8b14da2..88ba9e5 100644
--- a/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc
@@ -28,5 +28,5 @@
 namespace std
 {
   typedef short test_type;
-  template test_type&& forward(std::identity<test_type>::type&&);
+  template test_type&& forward<test_type>(test_type&&);
 }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc
index e8c751b..e2ec078 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc
@@ -66,7 +66,7 @@ test01()
 
   std::shared_ptr<A> a(new A);
   std::auto_ptr<B> b(new B);
-  a = b;
+  a = std::move(b);
   VERIFY( a.get() != 0 );
   VERIFY( b.get() == 0 );
   VERIFY( A::ctor_count == 2 );
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc
index 1554494..b79a25b 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc
@@ -36,7 +36,7 @@ test01()
 
   std::shared_ptr<A> a;
   std::auto_ptr<B> b;
-  a = b;                      // { dg-error "here" }
+  a = std::move(b);                      // { dg-error "here" }
 
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc
index 9087e51..eb5bb95 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc
@@ -33,7 +33,7 @@ test01()
   bool test __attribute__((unused)) = true;
 
   std::auto_ptr<A> a(new A);
-  std::shared_ptr<A> a2(a);
+  std::shared_ptr<A> a2(std::move(a));
   VERIFY( a.get() == 0 );
   VERIFY( a2.get() != 0 );
   VERIFY( a2.use_count() == 1 );
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc
index 3a946b5..e2ef60e 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc
@@ -34,7 +34,7 @@ test01()
   bool test __attribute__((unused)) = true;
 
   const std::auto_ptr<A> a;
-  std::shared_ptr<A> p(a); // { dg-error "no match" }
+  std::shared_ptr<A> p(std::move(a)); // { dg-error "no match" }
 
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/20_util/tuple/swap.cc b/libstdc++-v3/testsuite/20_util/tuple/swap.cc
index 6dab446..613e9c2 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/swap.cc
+++ b/libstdc++-v3/testsuite/20_util/tuple/swap.cc
@@ -41,7 +41,7 @@ struct MoveOnly
   bool operator==(MoveOnly const& m)
   { return i == m.i; }
 
-  void swap(MoveOnly&& m)
+  void swap(MoveOnly& m)
   { std::swap(m.i, i); }
 
   int i;
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc
index 0d9361a..8b5afdd 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc
@@ -39,7 +39,7 @@ test01()
 
   fwd_list_type x = {666.0, 777.0, 888.0};
 
-  a.splice_after(posa, x);
+  a.splice_after(posa, std::move(x));
 
   ++posa;
   VERIFY(*posa == 666.0);
@@ -70,7 +70,7 @@ test02()
   ++endy;
   VERIFY(*endy == 14.0);
 
-  a.splice_after(posa, y, befy, endy);
+  a.splice_after(posa, std::move(y), befy, endy);
   VERIFY(*posa == 0.0);
 
   VERIFY(*befy == 10.0);
@@ -95,7 +95,7 @@ test03()
   fwd_list_type::const_iterator posz = z.begin();
   VERIFY(*posz == 42.0);
 
-  a.splice_after(posa, z, posz);
+  a.splice_after(posa, std::move(z), posz);
   VERIFY(*posa == 1.0);
   ++posa;
   VERIFY(*posa == 43.0);
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc
index 434a9aa..13d15b3 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc
@@ -37,7 +37,7 @@ test01()
   fwd_list_type a = {0.0, 1.0, 2.0, 3.0, 4.0};
   fwd_list_type b = {1.0, 2.0, 3.0, 4.0, 4.0, 5.0};
 
-  a.merge(b);
+  a.merge(std::move(b));
 
   fwd_list_type r = {0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 4.0, 5.0};
 
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc
index 1f86db9..5a996f3 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc
@@ -34,7 +34,7 @@ test01()
 
   std::forward_list<double> x = {666.0, 777.0, 888.0};
 
-  a.splice_after(posa, x);
+  a.splice_after(posa, std::move(x));
 
   ++posa;
   VERIFY(*posa == 666.0);
@@ -63,7 +63,7 @@ test02()
   ++endy;
   VERIFY(*endy == 14.0);
 
-  a.splice_after(posa, y, befy, endy);
+  a.splice_after(posa, std::move(y), befy, endy);
   VERIFY(*posa == 0.0);
 
   VERIFY(*befy == 10.0);
@@ -86,7 +86,7 @@ test03()
   std::forward_list<double>::const_iterator posz = z.begin();
   VERIFY(*posz == 42.0);
 
-  a.splice_after(posa, z, posz);
+  a.splice_after(posa, std::move(z), posz);
   VERIFY(*posa == 1.0);
   ++posa;
   VERIFY(*posa == 43.0);
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc
index 05e3f84..1291a26 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc
@@ -32,7 +32,7 @@ test01()
   std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0};
   std::forward_list<double> b = {1.0, 2.0, 3.0, 4.0, 4.0, 5.0};
 
-  a.merge(b);
+  a.merge(std::move(b));
 
   std::forward_list<double> r = {0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0,
                                  4.0, 4.0, 4.0, 5.0};
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
index cd2b299..c0b6ea4 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1379 }
+// { dg-error "no matching" "" { target *-*-* } 1387 }
 // { dg-excess-errors "" }
 
 #include <list>
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
index cc2b419..0d27211 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1348 }
+// { dg-error "no matching" "" { target *-*-* } 1356 }
 // { dg-excess-errors "" }
 
 #include <list>
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
index d650a9e..bbf7808 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1348 }
+// { dg-error "no matching" "" { target *-*-* } 1356 }
 // { dg-excess-errors "" }
 
 #include <list>
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
index ae9e63f..1e84b97 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1348 }
+// { dg-error "no matching" "" { target *-*-* } 1356 }
 // { dg-excess-errors "" }
 
 #include <list>
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc b/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc
index 16954a1..b1940fa 100644
--- a/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc
@@ -25,7 +25,7 @@
 #include <future>
 #include <testsuite_hooks.h>
 
-extern std::unique_future<int>& get();
+extern std::unique_future<int>&& get();
 
 void test01()
 {
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc
index 7857e53..1ea66ec 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc
@@ -32,4 +32,4 @@ void test01()
 }
 
 // { dg-error "used here" "" { target *-*-* } 31 }
-// { dg-error "deleted function" "" { target *-*-* } 141 }
+// { dg-error "deleted function" "" { target *-*-* } 144 }
2009-07-31  Jason Merrill  <jason@redhat.com>

	* call.c (reference_binding): Rename lvalue_p to is_lvalue.
	Do direct binding of "rvalues" in memory to rvalue references.
	* tree.c (lvalue_p_1): Can't be both non-addressable lvalue and
	"rvalue" in memory.
	* typeck.c (build_static_cast_1): Do direct binding of memory
	"rvalues" to rvalue references.
	* cvt.c (cp_fold_convert): New.
	* cp-tree.h: Declare it.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 0254ecb..144d07e 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1205,7 +1205,7 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
   tree tfrom;
   bool related_p;
   bool compatible_p;
-  cp_lvalue_kind lvalue_p = clk_none;
+  cp_lvalue_kind is_lvalue = clk_none;
 
   if (TREE_CODE (to) == FUNCTION_TYPE && expr && type_unknown_p (expr))
     {
@@ -1218,7 +1218,7 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
   if (TREE_CODE (from) == REFERENCE_TYPE)
     {
       /* Anything with reference type is an lvalue.  */
-      lvalue_p = clk_ordinary;
+      is_lvalue = clk_ordinary;
       from = TREE_TYPE (from);
     }
 
@@ -1235,11 +1235,11 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
 	}
     }
 
-  if (lvalue_p == clk_none && expr)
-    lvalue_p = real_lvalue_p (expr);
+  if (is_lvalue == clk_none && expr)
+    is_lvalue = real_lvalue_p (expr);
 
   tfrom = from;
-  if ((lvalue_p & clk_bitfield) != 0)
+  if ((is_lvalue & clk_bitfield) != 0)
     tfrom = unlowered_expr_type (expr);
 
   /* Figure out whether or not the types are reference-related and
@@ -1256,12 +1256,15 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
   /* Directly bind reference when target expression's type is compatible with
      the reference and expression is an lvalue. In DR391, the wording in
      [8.5.3/5 dcl.init.ref] is changed to also require direct bindings for
-     const and rvalue references to rvalues of compatible class type. */
+     const and rvalue references to rvalues of compatible class type.
+     We should also do direct bindings for non-class "rvalues" derived from
+     rvalue references.  */
   if (compatible_p
-      && (lvalue_p
-	  || (!(flags & LOOKUP_NO_TEMP_BIND)
-	      && (CP_TYPE_CONST_NON_VOLATILE_P(to) || TYPE_REF_IS_RVALUE (rto))
-	      && CLASS_TYPE_P (from))))
+      && (is_lvalue
+	  || (((CP_TYPE_CONST_NON_VOLATILE_P (to)
+		&& !(flags & LOOKUP_NO_TEMP_BIND))
+	       || TYPE_REF_IS_RVALUE (rto))
+	      && (CLASS_TYPE_P (from) || (expr && lvalue_p (expr))))))
     {
       /* [dcl.init.ref]
 
@@ -1288,10 +1291,10 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
 	conv->rvaluedness_matches_p = TYPE_REF_IS_RVALUE (rto);
       else
 	conv->rvaluedness_matches_p 
-          = (TYPE_REF_IS_RVALUE (rto) == !lvalue_p);
+          = (TYPE_REF_IS_RVALUE (rto) == !is_lvalue);
 
-      if ((lvalue_p & clk_bitfield) != 0
-	  || ((lvalue_p & clk_packed) != 0 && !TYPE_PACKED (to)))
+      if ((is_lvalue & clk_bitfield) != 0
+	  || ((is_lvalue & clk_packed) != 0 && !TYPE_PACKED (to)))
 	/* For the purposes of overload resolution, we ignore the fact
 	   this expression is a bitfield or packed field. (In particular,
 	   [over.ics.ref] says specifically that a function with a
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index dcad934..07e89d3 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4339,6 +4339,7 @@ extern tree force_rvalue			(tree);
 extern tree ocp_convert				(tree, tree, int, int);
 extern tree cp_convert				(tree, tree);
 extern tree cp_convert_and_check                (tree, tree);
+extern tree cp_fold_convert			(tree, tree);
 extern tree convert_to_void	(tree, const char */*implicit context*/,
                                  tsubst_flags_t);
 extern tree convert_force			(tree, tree, int);
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index c42d21c..cdc6a10 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -539,7 +539,16 @@ force_rvalue (tree expr)
 
   return expr;
 }
+
 
+/* Fold away simple conversions, but make sure the result is an rvalue.  */
+
+tree
+cp_fold_convert (tree type, tree expr)
+{
+  return rvalue (fold_convert (type, expr));
+}
+
 /* C++ conversions, preference to static cast conversions.  */
 
 tree
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index cbadf04..9e194fc 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -214,10 +214,14 @@ lvalue_p_1 (const_tree ref)
   /* Otherwise, it's an lvalue, and it has all the odd properties
      contributed by either operand.  */
   op1_lvalue_kind = op1_lvalue_kind | op2_lvalue_kind;
-  /* It's not an ordinary lvalue if it involves either a bit-field or
-     a class rvalue.  */
+  /* It's not an ordinary lvalue if it involves any other kind.  */
   if ((op1_lvalue_kind & ~clk_ordinary) != clk_none)
     op1_lvalue_kind &= ~clk_ordinary;
+  /* It can't be both a pseudo-lvalue and a non-addressable lvalue.
+     A COND_EXPR of those should be wrapped in a TARGET_EXPR.  */
+  if ((op1_lvalue_kind & (clk_rvalueref|clk_class))
+      && (op1_lvalue_kind & (clk_bitfield|clk_packed)))
+    op1_lvalue_kind = clk_none;
   return op1_lvalue_kind;
 }
 
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 35c82d6..a956fdc 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5284,7 +5284,7 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p,
   if (TREE_CODE (type) == REFERENCE_TYPE
       && CLASS_TYPE_P (TREE_TYPE (type))
       && CLASS_TYPE_P (intype)
-      && real_lvalue_p (expr)
+      && (TYPE_REF_IS_RVALUE (type) || real_lvalue_p (expr))
       && DERIVED_FROM_P (intype, TREE_TYPE (type))
       && can_convert (build_pointer_type (TYPE_MAIN_VARIANT (intype)),
 		      build_pointer_type (TYPE_MAIN_VARIANT
@@ -5310,7 +5310,7 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p,
 			      base, /*nonnull=*/false);
       /* Convert the pointer to a reference -- but then remember that
 	 there are no expressions with reference type in C++.  */
-      return convert_from_reference (build_nop (type, expr));
+      return convert_from_reference (cp_fold_convert (type, expr));
     }
 
   orig = expr;
2009-07-31  Jason Merrill  <jason@redhat.com>

	* typeck.c (build_address): Do fold away ADDR_EXPR of INDIRECT_REF.
	* tree.c (rvalue): Use cp_build_qualified_type, not TYPE_MAIN_VARIANT.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 83869c1..cbadf04 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -530,7 +530,7 @@ rvalue (tree expr)
      Non-class rvalues always have cv-unqualified types.  */
   type = TREE_TYPE (expr);
   if (!CLASS_TYPE_P (type) && cp_type_quals (type))
-    type = TYPE_MAIN_VARIANT (type);
+    type = cp_build_qualified_type (type, TYPE_UNQUALIFIED);
 
   /* We need to do this for rvalue refs as well to get the right answer
      from decltype; see c++/36628.  */
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 8b684dd..35c82d6 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4276,21 +4276,18 @@ condition_conversion (tree expr)
   return t;
 }
 
-/* Return an ADDR_EXPR giving the address of T.  This function
-   attempts no optimizations or simplifications; it is a low-level
-   primitive.  */
+/* Returns the address of T.  This function will fold away
+   ADDR_EXPR of INDIRECT_REF.  */
 
 tree
 build_address (tree t)
 {
-  tree addr;
-
   if (error_operand_p (t) || !cxx_mark_addressable (t))
     return error_mark_node;
-
-  addr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t);
-
-  return addr;
+  t = build_fold_addr_expr (t);
+  if (TREE_CODE (t) != ADDR_EXPR)
+    t = rvalue (t);
+  return t;
 }
 
 /* Return a NOP_EXPR converting EXPR to TYPE.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]