@@ -593,13 +593,13 @@ bool Prescanner::SkipToNextSignificantCharacter() {
593
593
return false ;
594
594
} else {
595
595
auto anyContinuationLine{false };
596
- bool mightNeedSpace {false };
596
+ bool atNewline {false };
597
597
if (MustSkipToEndOfLine ()) {
598
598
SkipToEndOfLine ();
599
599
} else {
600
- mightNeedSpace = *at_ == ' \n ' ;
600
+ atNewline = *at_ == ' \n ' ;
601
601
}
602
- for (; Continuation (mightNeedSpace ); mightNeedSpace = false ) {
602
+ for (; Continuation (atNewline ); atNewline = false ) {
603
603
anyContinuationLine = true ;
604
604
++continuationLines_;
605
605
if (MustSkipToEndOfLine ()) {
@@ -641,7 +641,7 @@ void Prescanner::SkipSpaces() {
641
641
while (IsSpaceOrTab (at_)) {
642
642
NextChar ();
643
643
}
644
- insertASpace_ = false ;
644
+ brokenToken_ = false ;
645
645
}
646
646
647
647
const char *Prescanner::SkipWhiteSpace (const char *p) {
@@ -745,10 +745,7 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
745
745
}
746
746
}
747
747
}
748
- if (insertASpace_) {
749
- tokens.PutNextTokenChar (' ' , spaceProvenance_);
750
- insertASpace_ = false ;
751
- }
748
+ brokenToken_ = false ;
752
749
if (*at_ == ' \n ' ) {
753
750
return false ;
754
751
}
@@ -808,7 +805,7 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
808
805
bool anyDefined{false };
809
806
bool hadContinuation{false };
810
807
// Subtlety: When an identifier is split across continuation lines,
811
- // its parts are kept as distinct pp-tokens if that macro replacement
808
+ // its parts are kept as distinct pp-tokens if macro replacement
812
809
// should operate on them independently. This trick accommodates the
813
810
// historic practice of using line continuation for token pasting after
814
811
// replacement.
@@ -822,6 +819,9 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
822
819
++at_, ++column_;
823
820
hadContinuation = SkipToNextSignificantCharacter ();
824
821
if (hadContinuation && IsLegalIdentifierStart (*at_)) {
822
+ if (brokenToken_) {
823
+ break ;
824
+ }
825
825
// Continued identifier
826
826
tokens.CloseToken ();
827
827
++parts;
@@ -1348,7 +1348,7 @@ bool Prescanner::SkipCommentLine(bool afterAmpersand) {
1348
1348
return false ;
1349
1349
}
1350
1350
1351
- const char *Prescanner::FixedFormContinuationLine (bool mightNeedSpace ) {
1351
+ const char *Prescanner::FixedFormContinuationLine (bool atNewline ) {
1352
1352
if (IsAtEnd ()) {
1353
1353
return nullptr ;
1354
1354
}
@@ -1381,8 +1381,8 @@ const char *Prescanner::FixedFormContinuationLine(bool mightNeedSpace) {
1381
1381
}
1382
1382
const char *col6{nextLine_ + 5 };
1383
1383
if (*col6 != ' \n ' && *col6 != ' 0' && !IsSpaceOrTab (col6)) {
1384
- if (mightNeedSpace && !IsSpace (nextLine_ + 6 )) {
1385
- insertASpace_ = true ;
1384
+ if (atNewline && !IsSpace (nextLine_ + 6 )) {
1385
+ brokenToken_ = true ;
1386
1386
}
1387
1387
return nextLine_ + 6 ;
1388
1388
}
@@ -1395,7 +1395,9 @@ const char *Prescanner::FixedFormContinuationLine(bool mightNeedSpace) {
1395
1395
nextLine_[4 ] == ' ' && IsCompilerDirectiveSentinel (&nextLine_[1 ], 1 )) {
1396
1396
if (const char *col6{nextLine_ + 5 };
1397
1397
*col6 != ' \n ' && *col6 != ' 0' && !IsSpaceOrTab (col6)) {
1398
- insertASpace_ |= mightNeedSpace && !IsSpace (nextLine_ + 6 );
1398
+ if (atNewline && !IsSpace (nextLine_ + 6 )) {
1399
+ brokenToken_ = true ;
1400
+ }
1399
1401
return nextLine_ + 6 ;
1400
1402
} else {
1401
1403
return nullptr ;
@@ -1464,7 +1466,7 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
1464
1466
p = SkipWhiteSpace (p);
1465
1467
if (*p == ' &' ) {
1466
1468
if (!ampersand) {
1467
- insertASpace_ = true ;
1469
+ brokenToken_ = true ;
1468
1470
}
1469
1471
return p + 1 ;
1470
1472
} else if (ampersand) {
@@ -1494,22 +1496,22 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
1494
1496
} else if (p > lineStart && IsSpaceOrTab (p - 1 )) {
1495
1497
--p;
1496
1498
} else {
1497
- insertASpace_ = true ;
1499
+ brokenToken_ = true ;
1498
1500
}
1499
1501
return p;
1500
1502
} else {
1501
1503
return nullptr ;
1502
1504
}
1503
1505
}
1504
1506
1505
- bool Prescanner::FixedFormContinuation (bool mightNeedSpace ) {
1507
+ bool Prescanner::FixedFormContinuation (bool atNewline ) {
1506
1508
// N.B. We accept '&' as a continuation indicator in fixed form, too,
1507
1509
// but not in a character literal.
1508
1510
if (*at_ == ' &' && inCharLiteral_) {
1509
1511
return false ;
1510
1512
}
1511
1513
do {
1512
- if (const char *cont{FixedFormContinuationLine (mightNeedSpace )}) {
1514
+ if (const char *cont{FixedFormContinuationLine (atNewline )}) {
1513
1515
BeginSourceLine (cont);
1514
1516
column_ = 7 ;
1515
1517
NextLine ();
0 commit comments