Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang] Better error recovery for REAL(x, [KIND=]bad) #108222

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion flang/lib/Evaluate/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2264,7 +2264,7 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
messages.Say("'kind=' argument must be a constant scalar integer "
"whose value is a supported kind for the "
"intrinsic result type"_err_en_US);
return std::nullopt;
// use default kind below for error recovery
} else if (kindDummyArg->flags.test(ArgFlag::defaultsToSameKind)) {
CHECK(sameArg);
resultType = *sameArg->GetType();
Expand All @@ -2274,6 +2274,8 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
DynamicType{TypeCategory::Integer, defaults.sizeIntegerKind()};
} else {
CHECK(kindDummyArg->flags.test(ArgFlag::defaultsToDefaultForResult));
}
if (!resultType) {
int kind{defaults.GetDefaultKind(*category)};
if (*category == TypeCategory::Character) { // ACHAR & CHAR
resultType = DynamicType{kind, 1};
Expand Down
4 changes: 4 additions & 0 deletions flang/test/Semantics/kinds06.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
!RUN: %python %S/test_errors.py %s %flang_fc1
!ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
print *, real(1.,666)
end
Loading