@@ -188,14 +188,15 @@ void Prescanner::Statement() {
188188 }
189189 break ;
190190 }
191- case LineClassification::Kind::Source:
191+ case LineClassification::Kind::Source: {
192192 BeginStatementAndAdvance ();
193+ bool checkLabelField{false };
193194 if (inFixedForm_) {
194195 if (features_.IsEnabled (LanguageFeature::OldDebugLines) &&
195196 (*at_ == ' D' || *at_ == ' d' )) {
196197 NextChar ();
197198 }
198- LabelField (tokens) ;
199+ checkLabelField = true ;
199200 } else {
200201 if (skipLeadingAmpersand_) {
201202 skipLeadingAmpersand_ = false ;
@@ -207,38 +208,42 @@ void Prescanner::Statement() {
207208 } else {
208209 SkipSpaces ();
209210 }
210- // Check for a leading identifier that might be a keyword macro
211- // that will expand to anything indicating a non-source line, like
212- // a comment marker or directive sentinel. If so, disable line
213- // continuation, so that NextToken() won't consume anything from
214- // following lines.
215- if (IsLegalIdentifierStart (*at_)) {
216- // TODO: Only bother with these cases when any keyword macro has
217- // been defined with replacement text that could begin a comment
218- // or directive sentinel.
219- const char *p{at_};
220- while (IsLegalInIdentifier (*++p)) {
221- }
222- CharBlock id{at_, static_cast <std::size_t >(p - at_)};
223- if (preprocessor_.IsNameDefined (id) &&
224- !preprocessor_.IsFunctionLikeDefinition (id)) {
225- TokenSequence toks;
226- toks.Put (id, GetProvenance (at_));
227- if (auto replaced{preprocessor_.MacroReplacement (toks, *this )}) {
228- auto newLineClass{ClassifyLine (*replaced, GetCurrentProvenance ())};
229- if (newLineClass.kind ==
230- LineClassification::Kind::CompilerDirective) {
231- directiveSentinel_ = newLineClass.sentinel ;
232- disableSourceContinuation_ = false ;
233- } else {
234- disableSourceContinuation_ =
235- newLineClass.kind != LineClassification::Kind::Source;
236- }
211+ }
212+ // Check for a leading identifier that might be a keyword macro
213+ // that will expand to anything indicating a non-source line, like
214+ // a comment marker or directive sentinel. If so, disable line
215+ // continuation, so that NextToken() won't consume anything from
216+ // following lines.
217+ if (IsLegalIdentifierStart (*at_)) {
218+ // TODO: Only bother with these cases when any keyword macro has
219+ // been defined with replacement text that could begin a comment
220+ // or directive sentinel.
221+ const char *p{at_};
222+ while (IsLegalInIdentifier (*++p)) {
223+ }
224+ CharBlock id{at_, static_cast <std::size_t >(p - at_)};
225+ if (preprocessor_.IsNameDefined (id) &&
226+ !preprocessor_.IsFunctionLikeDefinition (id)) {
227+ checkLabelField = false ;
228+ TokenSequence toks;
229+ toks.Put (id, GetProvenance (at_));
230+ if (auto replaced{preprocessor_.MacroReplacement (toks, *this )}) {
231+ auto newLineClass{ClassifyLine (*replaced, GetCurrentProvenance ())};
232+ if (newLineClass.kind ==
233+ LineClassification::Kind::CompilerDirective) {
234+ directiveSentinel_ = newLineClass.sentinel ;
235+ disableSourceContinuation_ = false ;
236+ } else {
237+ disableSourceContinuation_ =
238+ newLineClass.kind != LineClassification::Kind::Source;
237239 }
238240 }
239241 }
240242 }
241- break ;
243+ if (checkLabelField) {
244+ LabelField (tokens);
245+ }
246+ } break ;
242247 }
243248
244249 while (NextToken (tokens)) {
0 commit comments