Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[flang] Add control and a portability warning for an extension #137995

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

Merged
merged 1 commit into from
May 12, 2025
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
2 changes: 1 addition & 1 deletion 2 flang/include/flang/Support/Fortran-features.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
PolymorphicActualAllocatableOrPointerToMonomorphicDummy, RelaxedPureDummy,
UndefinableAsynchronousOrVolatileActual, AutomaticInMainProgram, PrintCptr,
SavedLocalInSpecExpr, PrintNamelist, AssumedRankPassedToNonAssumedRank,
IgnoreIrrelevantAttributes, Unsigned)
IgnoreIrrelevantAttributes, Unsigned, ContiguousOkForSeqAssociation)

// Portability and suspicious usage warnings
ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
Expand Down
36 changes: 27 additions & 9 deletions 36 flang/lib/Semantics/check-call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,20 +581,38 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
"Polymorphic scalar may not be associated with a %s array"_err_en_US,
dummyName);
}
bool isOkBecauseContiguous{
context.IsEnabled(
common::LanguageFeature::ContiguousOkForSeqAssociation) &&
actualLastSymbol &&
evaluate::IsContiguous(*actualLastSymbol, foldingContext)};
if (actualIsArrayElement && actualLastSymbol &&
!evaluate::IsContiguous(*actualLastSymbol, foldingContext) &&
!dummy.ignoreTKR.test(common::IgnoreTKR::Contiguous)) {
if (IsPointer(*actualLastSymbol)) {
basicError = true;
messages.Say(
"Element of pointer array may not be associated with a %s array"_err_en_US,
dummyName);
if (isOkBecauseContiguous) {
akuhlens marked this conversation as resolved.
Show resolved Hide resolved
context.Warn(
common::LanguageFeature::ContiguousOkForSeqAssociation,
messages.at(),
"Element of contiguous pointer array is accepted for storage sequence association"_port_en_US);
} else {
basicError = true;
messages.Say(
"Element of pointer array may not be associated with a %s array"_err_en_US,
dummyName);
}
} else if (IsAssumedShape(*actualLastSymbol) &&
!dummy.ignoreTKR.test(common::IgnoreTKR::Contiguous)) {
basicError = true;
messages.Say(
"Element of assumed-shape array may not be associated with a %s array"_err_en_US,
dummyName);
if (isOkBecauseContiguous) {
context.Warn(
common::LanguageFeature::ContiguousOkForSeqAssociation,
messages.at(),
"Element of contiguous assumed-shape array is accepted for storage sequence association"_port_en_US);
} else {
basicError = true;
messages.Say(
"Element of assumed-shape array may not be associated with a %s array"_err_en_US,
dummyName);
}
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions 13 flang/test/Semantics/call44.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror
subroutine assumedshape(normal, contig)
real normal(:)
real, contiguous :: contig(:)
!WARNING: If the procedure's interface were explicit, this reference would be in error
!BECAUSE: Element of assumed-shape array may not be associated with a dummy argument 'assumedsize=' array
call seqAssociate(normal(1))
!PORTABILITY: Element of contiguous assumed-shape array is accepted for storage sequence association
call seqAssociate(contig(1))
end
subroutine seqAssociate(assumedSize)
real assumedSize(*)
end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.