@@ -1267,20 +1267,6 @@ struct FindLocalExternScope {
1267
1267
LookupResult &R;
1268
1268
bool OldFindLocalExtern;
1269
1269
};
1270
-
1271
- // / Returns true if 'operator=' should be treated as a dependent name.
1272
- bool isDependentAssignmentOperator (DeclarationName Name,
1273
- DeclContext *LookupContext) {
1274
- const auto *LookupRecord = dyn_cast_if_present<CXXRecordDecl>(LookupContext);
1275
- // If the lookup context is the current instantiation but we are outside a
1276
- // complete-class context, we will never find the implicitly declared
1277
- // copy/move assignment operators because they are declared at the closing '}'
1278
- // of the class specifier. In such cases, we treat 'operator=' like any other
1279
- // unqualified name because the results of name lookup in the template
1280
- // definition/instantiation context will always be the same.
1281
- return Name.getCXXOverloadedOperator () == OO_Equal && LookupRecord &&
1282
- !LookupRecord->isBeingDefined () && LookupRecord->isDependentContext ();
1283
- }
1284
1270
} // end anonymous namespace
1285
1271
1286
1272
bool Sema::CppLookupName (LookupResult &R, Scope *S) {
@@ -1289,6 +1275,13 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) {
1289
1275
DeclarationName Name = R.getLookupName ();
1290
1276
Sema::LookupNameKind NameKind = R.getLookupKind ();
1291
1277
1278
+ // If this is the name of an implicitly-declared special member function,
1279
+ // go through the scope stack to implicitly declare
1280
+ if (isImplicitlyDeclaredMemberFunctionName (Name)) {
1281
+ for (Scope *PreS = S; PreS; PreS = PreS->getParent ())
1282
+ if (DeclContext *DC = PreS->getEntity ())
1283
+ DeclareImplicitMemberFunctionsWithName (*this , Name, R.getNameLoc (), DC);
1284
+ }
1292
1285
// C++23 [temp.dep.general]p2:
1293
1286
// The component name of an unqualified-id is dependent if
1294
1287
// - it is a conversion-function-id whose conversion-type-id
@@ -1306,8 +1299,9 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) {
1306
1299
if (isImplicitlyDeclaredMemberFunctionName (Name)) {
1307
1300
for (Scope *PreS = S; PreS; PreS = PreS->getParent ())
1308
1301
if (DeclContext *DC = PreS->getEntity ()) {
1309
- if (!R.isTemplateNameLookup () &&
1310
- isDependentAssignmentOperator (Name, DC)) {
1302
+ if (DC->isDependentContext () && isa<CXXRecordDecl>(DC) &&
1303
+ Name.getCXXOverloadedOperator () == OO_Equal &&
1304
+ !R.isTemplateNameLookup ()) {
1311
1305
R.setNotFoundInCurrentInstantiation ();
1312
1306
return false ;
1313
1307
}
@@ -2478,6 +2472,8 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
2478
2472
}
2479
2473
} QL (LookupCtx);
2480
2474
2475
+ bool TemplateNameLookup = R.isTemplateNameLookup ();
2476
+ CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx);
2481
2477
if (!InUnqualifiedLookup && !R.isForRedeclaration ()) {
2482
2478
// C++23 [temp.dep.type]p5:
2483
2479
// A qualified name is dependent if
@@ -2490,14 +2486,13 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
2490
2486
if (DeclarationName Name = R.getLookupName ();
2491
2487
(Name.getNameKind () == DeclarationName::CXXConversionFunctionName &&
2492
2488
Name.getCXXNameType ()->isDependentType ()) ||
2493
- (!R. isTemplateNameLookup () &&
2494
- isDependentAssignmentOperator (Name, LookupCtx) )) {
2489
+ (Name. getCXXOverloadedOperator () == OO_Equal && LookupRec &&
2490
+ LookupRec-> isDependentContext () && !TemplateNameLookup )) {
2495
2491
R.setNotFoundInCurrentInstantiation ();
2496
2492
return false ;
2497
2493
}
2498
2494
}
2499
2495
2500
- CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx);
2501
2496
if (LookupDirect (*this , R, LookupCtx)) {
2502
2497
R.resolveKind ();
2503
2498
if (LookupRec)
@@ -2609,7 +2604,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
2609
2604
// template, and if the name is used as a template-name, the
2610
2605
// reference refers to the class template itself and not a
2611
2606
// specialization thereof, and is not ambiguous.
2612
- if (R. isTemplateNameLookup () )
2607
+ if (TemplateNameLookup )
2613
2608
if (auto *TD = getAsTemplateNameDecl (ND))
2614
2609
ND = TD;
2615
2610
0 commit comments