@@ -593,13 +593,13 @@ bool Prescanner::SkipToNextSignificantCharacter() {
593593 return false ;
594594 } else {
595595 auto anyContinuationLine{false };
596- bool mightNeedSpace {false };
596+ bool atNewline {false };
597597 if (MustSkipToEndOfLine ()) {
598598 SkipToEndOfLine ();
599599 } else {
600- mightNeedSpace = *at_ == ' \n ' ;
600+ atNewline = *at_ == ' \n ' ;
601601 }
602- for (; Continuation (mightNeedSpace ); mightNeedSpace = false ) {
602+ for (; Continuation (atNewline ); atNewline = false ) {
603603 anyContinuationLine = true ;
604604 ++continuationLines_;
605605 if (MustSkipToEndOfLine ()) {
@@ -641,7 +641,7 @@ void Prescanner::SkipSpaces() {
641641 while (IsSpaceOrTab (at_)) {
642642 NextChar ();
643643 }
644- insertASpace_ = false ;
644+ brokenToken_ = false ;
645645}
646646
647647const char *Prescanner::SkipWhiteSpace (const char *p) {
@@ -745,10 +745,7 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
745745 }
746746 }
747747 }
748- if (insertASpace_) {
749- tokens.PutNextTokenChar (' ' , spaceProvenance_);
750- insertASpace_ = false ;
751- }
748+ brokenToken_ = false ;
752749 if (*at_ == ' \n ' ) {
753750 return false ;
754751 }
@@ -808,7 +805,7 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
808805 bool anyDefined{false };
809806 bool hadContinuation{false };
810807 // 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
812809 // should operate on them independently. This trick accommodates the
813810 // historic practice of using line continuation for token pasting after
814811 // replacement.
@@ -822,6 +819,9 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
822819 ++at_, ++column_;
823820 hadContinuation = SkipToNextSignificantCharacter ();
824821 if (hadContinuation && IsLegalIdentifierStart (*at_)) {
822+ if (brokenToken_) {
823+ break ;
824+ }
825825 // Continued identifier
826826 tokens.CloseToken ();
827827 ++parts;
@@ -1348,7 +1348,7 @@ bool Prescanner::SkipCommentLine(bool afterAmpersand) {
13481348 return false ;
13491349}
13501350
1351- const char *Prescanner::FixedFormContinuationLine (bool mightNeedSpace ) {
1351+ const char *Prescanner::FixedFormContinuationLine (bool atNewline ) {
13521352 if (IsAtEnd ()) {
13531353 return nullptr ;
13541354 }
@@ -1381,8 +1381,8 @@ const char *Prescanner::FixedFormContinuationLine(bool mightNeedSpace) {
13811381 }
13821382 const char *col6{nextLine_ + 5 };
13831383 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 ;
13861386 }
13871387 return nextLine_ + 6 ;
13881388 }
@@ -1395,7 +1395,9 @@ const char *Prescanner::FixedFormContinuationLine(bool mightNeedSpace) {
13951395 nextLine_[4 ] == ' ' && IsCompilerDirectiveSentinel (&nextLine_[1 ], 1 )) {
13961396 if (const char *col6{nextLine_ + 5 };
13971397 *col6 != ' \n ' && *col6 != ' 0' && !IsSpaceOrTab (col6)) {
1398- insertASpace_ |= mightNeedSpace && !IsSpace (nextLine_ + 6 );
1398+ if (atNewline && !IsSpace (nextLine_ + 6 )) {
1399+ brokenToken_ = true ;
1400+ }
13991401 return nextLine_ + 6 ;
14001402 } else {
14011403 return nullptr ;
@@ -1464,7 +1466,7 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
14641466 p = SkipWhiteSpace (p);
14651467 if (*p == ' &' ) {
14661468 if (!ampersand) {
1467- insertASpace_ = true ;
1469+ brokenToken_ = true ;
14681470 }
14691471 return p + 1 ;
14701472 } else if (ampersand) {
@@ -1494,22 +1496,22 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
14941496 } else if (p > lineStart && IsSpaceOrTab (p - 1 )) {
14951497 --p;
14961498 } else {
1497- insertASpace_ = true ;
1499+ brokenToken_ = true ;
14981500 }
14991501 return p;
15001502 } else {
15011503 return nullptr ;
15021504 }
15031505}
15041506
1505- bool Prescanner::FixedFormContinuation (bool mightNeedSpace ) {
1507+ bool Prescanner::FixedFormContinuation (bool atNewline ) {
15061508 // N.B. We accept '&' as a continuation indicator in fixed form, too,
15071509 // but not in a character literal.
15081510 if (*at_ == ' &' && inCharLiteral_) {
15091511 return false ;
15101512 }
15111513 do {
1512- if (const char *cont{FixedFormContinuationLine (mightNeedSpace )}) {
1514+ if (const char *cont{FixedFormContinuationLine (atNewline )}) {
15131515 BeginSourceLine (cont);
15141516 column_ = 7 ;
15151517 NextLine ();
0 commit comments