r179941 - Implement core issue 1608: class members can be found via operator lookup in a trailing return type in that class's body.

Richard Smith richard-llvm at metafoo.co.uk
Sat Apr 20 05:41:23 PDT 2013


Author: rsmith
Date: Sat Apr 20 07:41:22 2013
New Revision: 179941

URL: http://llvm.org/viewvc/llvm-project?rev=179941&view=rev
Log:
Implement core issue 1608: class members can be found via operator lookup in a trailing return type in that class's body.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/trailing-return-0x.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=179941&r1=179940&r2=179941&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Apr 20 07:41:22 2013
@@ -6018,13 +6018,15 @@ void Sema::AddMemberOperatorCandidates(O
   //   constructed as follows:
   QualType T1 = Args[0]->getType();
 
-  //     -- If T1 is a class type, the set of member candidates is the
-  //        result of the qualified lookup of T1::operator@
-  //        (13.3.1.1.1); otherwise, the set of member candidates is
-  //        empty.
+  //     -- If T1 is a complete class type or a class currently being
+  //        defined, the set of member candidates is the result of the
+  //        qualified lookup of T1::operator@ (13.3.1.1.1); otherwise,
+  //        the set of member candidates is empty.
   if (const RecordType *T1Rec = T1->getAs<RecordType>()) {
-    // Complete the type if it can be completed. Otherwise, we're done.
-    if (RequireCompleteType(OpLoc, T1, 0))
+    // Complete the type if it can be completed.
+    RequireCompleteType(OpLoc, T1, 0);
+    // If the type is neither complete nor being defined, bail out now.
+    if (!T1Rec->getDecl()->getDefinition())
       return;
 
     LookupResult Operators(*this, OpName, OpLoc, LookupOrdinaryName);

Modified: cfe/trunk/test/SemaCXX/trailing-return-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/trailing-return-0x.cpp?rev=179941&r1=179940&r2=179941&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/trailing-return-0x.cpp (original)
+++ cfe/trunk/test/SemaCXX/trailing-return-0x.cpp Sat Apr 20 07:41:22 2013
@@ -85,3 +85,12 @@ namespace PR12053 {
     f2(0); // expected-error{{no matching function for call to 'f2'}}
   }
 }
+
+namespace DR1608 {
+  struct S {
+    void operator+();
+    int operator[](int);
+    auto f() -> decltype(+*this); // expected-note {{here}}
+    auto f() -> decltype((*this)[0]); // expected-error {{cannot be overloaded}}
+  };
+}





More information about the cfe-commits mailing list