@@ -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,14 @@ 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
+ }
1285
+
1292
1286
// C++23 [temp.dep.general]p2:
1293
1287
// The component name of an unqualified-id is dependent if
1294
1288
// - it is a conversion-function-id whose conversion-type-id
@@ -1301,20 +1295,6 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) {
1301
1295
return false ;
1302
1296
}
1303
1297
1304
- // If this is the name of an implicitly-declared special member function,
1305
- // go through the scope stack to implicitly declare
1306
- if (isImplicitlyDeclaredMemberFunctionName (Name)) {
1307
- for (Scope *PreS = S; PreS; PreS = PreS->getParent ())
1308
- if (DeclContext *DC = PreS->getEntity ()) {
1309
- if (!R.isTemplateNameLookup () &&
1310
- isDependentAssignmentOperator (Name, DC)) {
1311
- R.setNotFoundInCurrentInstantiation ();
1312
- return false ;
1313
- }
1314
- DeclareImplicitMemberFunctionsWithName (*this , Name, R.getNameLoc (), DC);
1315
- }
1316
- }
1317
-
1318
1298
// Implicitly declare member functions with the name we're looking for, if in
1319
1299
// fact we are in a scope where it matters.
1320
1300
@@ -2478,6 +2458,10 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
2478
2458
}
2479
2459
} QL (LookupCtx);
2480
2460
2461
+ CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx);
2462
+ // FIXME: Per [temp.dep.general]p2, an unqualified name is also dependent
2463
+ // if it's a dependent conversion-function-id or operator= where the current
2464
+ // class is a templated entity. This should be handled in LookupName.
2481
2465
if (!InUnqualifiedLookup && !R.isForRedeclaration ()) {
2482
2466
// C++23 [temp.dep.type]p5:
2483
2467
// A qualified name is dependent if
@@ -2488,16 +2472,13 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
2488
2472
// is operator=, or
2489
2473
// - [...]
2490
2474
if (DeclarationName Name = R.getLookupName ();
2491
- (Name.getNameKind () == DeclarationName::CXXConversionFunctionName &&
2492
- Name.getCXXNameType ()->isDependentType ()) ||
2493
- (!R.isTemplateNameLookup () &&
2494
- isDependentAssignmentOperator (Name, LookupCtx))) {
2475
+ Name.getNameKind () == DeclarationName::CXXConversionFunctionName &&
2476
+ Name.getCXXNameType ()->isDependentType ()) {
2495
2477
R.setNotFoundInCurrentInstantiation ();
2496
2478
return false ;
2497
2479
}
2498
2480
}
2499
2481
2500
- CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx);
2501
2482
if (LookupDirect (*this , R, LookupCtx)) {
2502
2483
R.resolveKind ();
2503
2484
if (LookupRec)
@@ -2588,6 +2569,8 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
2588
2569
return true ;
2589
2570
};
2590
2571
2572
+ bool TemplateNameLookup = R.isTemplateNameLookup ();
2573
+
2591
2574
// Determine whether two sets of members contain the same members, as
2592
2575
// required by C++ [class.member.lookup]p6.
2593
2576
auto HasSameDeclarations = [&](DeclContext::lookup_iterator A,
@@ -2609,7 +2592,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
2609
2592
// template, and if the name is used as a template-name, the
2610
2593
// reference refers to the class template itself and not a
2611
2594
// specialization thereof, and is not ambiguous.
2612
- if (R. isTemplateNameLookup () )
2595
+ if (TemplateNameLookup )
2613
2596
if (auto *TD = getAsTemplateNameDecl (ND))
2614
2597
ND = TD;
2615
2598
0 commit comments