[cfe-commits] r67397 - in /cfe/trunk: lib/AST/DeclCXX.cpp test/Parser/cxx0x-rvalue-reference.cpp test/SemaCXX/rval-references.cpp

Douglas Gregor dgregor at apple.com
Fri Mar 20 13:21:37 PDT 2009


Author: dgregor
Date: Fri Mar 20 15:21:37 2009
New Revision: 67397

URL: http://llvm.org/viewvc/llvm-project?rev=67397&view=rev
Log:
Some minor tweaks and additional tests for rvalue references

Modified:
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/test/Parser/cxx0x-rvalue-reference.cpp
    cfe/trunk/test/SemaCXX/rval-references.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=67397&r1=67396&r2=67397&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Mar 20 15:21:37 2009
@@ -104,7 +104,7 @@
     QualType ArgType = FnType->getArgType(0);
     if (const LValueReferenceType *Ref = ArgType->getAsLValueReferenceType()) {
       ArgType = Ref->getPointeeType();
-      // Is it a non-const reference?
+      // Is it a non-const lvalue reference?
       if (!ArgType.isConstQualified())
         AcceptsConst = false;
     }

Modified: cfe/trunk/test/Parser/cxx0x-rvalue-reference.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-rvalue-reference.cpp?rev=67397&r1=67396&r2=67397&view=diff

==============================================================================
--- cfe/trunk/test/Parser/cxx0x-rvalue-reference.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-rvalue-reference.cpp Fri Mar 20 15:21:37 2009
@@ -3,4 +3,7 @@
 int && r1(int &&a);
 
 typedef int && R;
-void r2(const R a);
+void r2(const R a) {
+  int & &&ar = a; // expected-error{{'ar' declared as a reference to a reference}}
+}
+

Modified: cfe/trunk/test/SemaCXX/rval-references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/rval-references.cpp?rev=67397&r1=67396&r2=67397&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/rval-references.cpp (original)
+++ cfe/trunk/test/SemaCXX/rval-references.cpp Fri Mar 20 15:21:37 2009
@@ -14,11 +14,17 @@
 int over(int&);
 not_int over(int&&);
 
+int over2(const int&);
+not_int over2(int&&);
+
+struct conv_to_not_int_rvalue {
+  operator not_int &&();
+};
+
 void f() {
   int &&virr1; // expected-error {{declaration of reference variable 'virr1' requires an initializer}}
   int &&virr2 = 0;
-  // FIXME: named rvalue references are lvalues!
-  //int &&virr3 = virr1; // xpected-error {{rvalue reference cannot bind to lvalue}}
+  int &&virr3 = virr2; // expected-error {{rvalue reference cannot bind to lvalue}}
   int i1 = 0;
   int &&virr4 = i1; // expected-error {{rvalue reference cannot bind to lvalue}}
   int &&virr5 = ret_irr();
@@ -28,6 +34,13 @@
   int i3 = over(virr2);
   not_int ni2 = over(ret_irr());
 
+  int i4 = over2(i1);
+  // not_int ni3 = over2(0); FIXME: this should be well-formed.
+
   ilr_c1 vilr1 = i1;
   ilr_c2 vilr2 = i1;
+
+  conv_to_not_int_rvalue cnir;
+  not_int &&ni4 = cnir;
+  not_int &ni5 = cnir; // expected-error{{non-const lvalue reference to type 'struct not_int' cannot be initialized with a value of type 'struct conv_to_not_int_rvalue'}}
 }





More information about the cfe-commits mailing list