@@ -188,14 +188,15 @@ void Prescanner::Statement() {
188
188
}
189
189
break ;
190
190
}
191
- case LineClassification::Kind::Source:
191
+ case LineClassification::Kind::Source: {
192
192
BeginStatementAndAdvance ();
193
+ bool checkLabelField{false };
193
194
if (inFixedForm_) {
194
195
if (features_.IsEnabled (LanguageFeature::OldDebugLines) &&
195
196
(*at_ == ' D' || *at_ == ' d' )) {
196
197
NextChar ();
197
198
}
198
- LabelField (tokens) ;
199
+ checkLabelField = true ;
199
200
} else {
200
201
if (skipLeadingAmpersand_) {
201
202
skipLeadingAmpersand_ = false ;
@@ -207,38 +208,42 @@ void Prescanner::Statement() {
207
208
} else {
208
209
SkipSpaces ();
209
210
}
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;
237
239
}
238
240
}
239
241
}
240
242
}
241
- break ;
243
+ if (checkLabelField) {
244
+ LabelField (tokens);
245
+ }
246
+ } break ;
242
247
}
243
248
244
249
while (NextToken (tokens)) {
0 commit comments