diff options
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 14 | ||||
-rw-r--r-- | test/SemaCXX/trailing-return-0x.cpp | 9 |
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 4576a0eab2..1b22102d19 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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); diff --git a/test/SemaCXX/trailing-return-0x.cpp b/test/SemaCXX/trailing-return-0x.cpp index 462b4fa3da..bd601db2ac 100644 --- a/test/SemaCXX/trailing-return-0x.cpp +++ b/test/SemaCXX/trailing-return-0x.cpp @@ -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}} + }; +} |