]> granicus.if.org Git - clang/commitdiff
Implement core issue 1608: class members can be found via operator lookup in a traili...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 20 Apr 2013 12:41:22 +0000 (12:41 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 20 Apr 2013 12:41:22 +0000 (12:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179941 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/trailing-return-0x.cpp

index 4576a0eab2c22dea1eaaa5af7e9a7368d60ab588..1b22102d19557b300e155095fd118820c8903d5c 100644 (file)
@@ -6018,13 +6018,15 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op,
   //   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);
index 462b4fa3da0999e28dc90783e1dca65c8733b33b..bd601db2ac1d4b60b5ff5b5550b6d7e07d10a69b 100644 (file)
@@ -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}}
+  };
+}