* The legacy extension intrinsic functions `IZEXT` and `JZEXT`
are supported; `ZEXT` has different behavior with various older
compilers, so it is not supported.
+* f18 doesn't impose a limit on the number of continuation lines
+ allowed for a single statement.
### Extensions supported when enabled by options
void Prescanner::Statement() {
TokenSequence tokens;
- LineClassification line{ClassifyLine(nextLine_)};
+ const char *statementStart{nextLine_};
+ LineClassification line{ClassifyLine(statementStart)};
switch (line.kind) {
case LineClassification::Kind::Comment:
nextLine_ += line.payloadOffset; // advance to '!' or newline
while (NextToken(tokens)) {
}
+ if (continuationLines_ > 255) {
+ Say(GetProvenance(statementStart),
+ "%d continuation lines is more than the Fortran standard allows"_port_en_US,
+ continuationLines_);
+ }
Provenance newlineProvenance{GetCurrentProvenance()};
if (std::optional<TokenSequence> preprocessed{
token.CloseToken();
SkipToNextSignificantCharacter();
if (IsDecimalDigit(*at_)) {
- Say(GetProvenance(at_),
+ Say(GetCurrentProvenance(),
"Label digit is not in fixed-form label field"_port_en_US);
}
}
mightNeedSpace = *at_ == '\n';
}
for (; Continuation(mightNeedSpace); mightNeedSpace = false) {
+ ++continuationLines_;
if (MustSkipToEndOfLine()) {
SkipToEndOfLine();
}
// Recognize and skip over classic C style /*comments*/ when
// outside a character literal.
if (features_.ShouldWarn(LanguageFeature::ClassicCComments)) {
- Say(GetProvenance(at_),
+ Say(GetCurrentProvenance(),
"nonstandard usage: C-style comment"_port_en_US);
}
SkipCComments();
slashInCurrentStatement_ = false;
preventHollerith_ = false;
delimiterNesting_ = 0;
+ continuationLines_ = 0;
}
Provenance GetProvenance(const char *sourceChar) const {
Encoding encoding_{Encoding::UTF_8};
int delimiterNesting_{0};
int prescannerNesting_{0};
+ int continuationLines_{0};
Provenance startProvenance_;
const char *start_{nullptr}; // beginning of current source file content
--- /dev/null
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
+! CHECK: portability: 256 continuation lines is more than the Fortran standard allows
+! CHECK: LOGICAL, PARAMETER :: c255 = .true._4
+program test
+ logical, parameter ::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