@@ -2420,7 +2420,7 @@ Decl *Parser::ParseModuleImport(SourceLocation AtLoc,
2420
2420
2421
2421
// For C++20 modules, we can have "name" or ":Partition name" as valid input.
2422
2422
SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2 > Path;
2423
- SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2 > Partition ;
2423
+ bool IsPartition = false ;
2424
2424
Module *HeaderUnit = nullptr ;
2425
2425
if (Tok.is (tok::header_name)) {
2426
2426
// This is a header import that the preprocessor decided we should skip
@@ -2435,10 +2435,12 @@ Decl *Parser::ParseModuleImport(SourceLocation AtLoc,
2435
2435
SourceLocation ColonLoc = ConsumeToken ();
2436
2436
if (!getLangOpts ().CPlusPlusModules )
2437
2437
Diag (ColonLoc, diag::err_unsupported_module_partition)
2438
- << SourceRange (ColonLoc, Partition .back ().second );
2438
+ << SourceRange (ColonLoc, Path .back ().second );
2439
2439
// Recover by leaving partition empty.
2440
- else if (ParseModuleName (ColonLoc, Partition , /* IsImport*/ true ))
2440
+ else if (ParseModuleName (ColonLoc, Path , /* IsImport*/ true ))
2441
2441
return nullptr ;
2442
+ else
2443
+ IsPartition = true ;
2442
2444
} else {
2443
2445
if (ParseModuleName (ImportLoc, Path, /* IsImport*/ true ))
2444
2446
return nullptr ;
@@ -2457,15 +2459,14 @@ Decl *Parser::ParseModuleImport(SourceLocation AtLoc,
2457
2459
2458
2460
// Diagnose mis-imports.
2459
2461
bool SeenError = true ;
2460
- bool HasPart = !Partition.empty ();
2461
2462
switch (ImportState) {
2462
2463
case Sema::ModuleImportState::ImportAllowed:
2463
2464
SeenError = false ;
2464
2465
break ;
2465
2466
case Sema::ModuleImportState::FirstDecl:
2466
2467
case Sema::ModuleImportState::NotACXX20Module:
2467
2468
// We can only import a partition within a module purview.
2468
- if (HasPart )
2469
+ if (IsPartition )
2469
2470
Diag (ImportLoc, diag::err_partition_import_outside_module);
2470
2471
else
2471
2472
SeenError = false ;
@@ -2474,7 +2475,7 @@ Decl *Parser::ParseModuleImport(SourceLocation AtLoc,
2474
2475
// We can only have pre-processor directives in the global module
2475
2476
// fragment. We can, however have a header unit import here.
2476
2477
if (!HeaderUnit)
2477
- Diag (ImportLoc, diag::err_import_in_wrong_fragment) << HasPart << 0 ;
2478
+ Diag (ImportLoc, diag::err_import_in_wrong_fragment) << IsPartition << 0 ;
2478
2479
else
2479
2480
SeenError = false ;
2480
2481
break ;
@@ -2485,7 +2486,7 @@ Decl *Parser::ParseModuleImport(SourceLocation AtLoc,
2485
2486
SeenError = false ;
2486
2487
break ;
2487
2488
case Sema::ModuleImportState::PrivateFragment:
2488
- Diag (ImportLoc, diag::err_import_in_wrong_fragment) << HasPart << 1 ;
2489
+ Diag (ImportLoc, diag::err_import_in_wrong_fragment) << IsPartition << 1 ;
2489
2490
break ;
2490
2491
}
2491
2492
if (SeenError) {
@@ -2497,9 +2498,9 @@ Decl *Parser::ParseModuleImport(SourceLocation AtLoc,
2497
2498
if (HeaderUnit)
2498
2499
Import =
2499
2500
Actions.ActOnModuleImport (StartLoc, ExportLoc, ImportLoc, HeaderUnit);
2500
- else if (!Path.empty () || !Partition. empty () )
2501
+ else if (!Path.empty ())
2501
2502
Import = Actions.ActOnModuleImport (StartLoc, ExportLoc, ImportLoc, Path,
2502
- Partition );
2503
+ IsPartition );
2503
2504
ExpectAndConsumeSemi (diag::err_module_expected_semi);
2504
2505
if (Import.isInvalid ())
2505
2506
return nullptr ;
0 commit comments