Skip to content

[flang][OpenMP] Fix 2 more regressions after #101009 #101538

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
Aug 15, 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
3 changes: 2 additions & 1 deletion flang/lib/Semantics/check-call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,8 @@ static void CheckPresent(evaluate::ActualArguments &arguments,
} else {
symbol = arg->GetAssumedTypeDummy();
}
if (!symbol || !symbol->attrs().test(semantics::Attr::OPTIONAL)) {
if (!symbol ||
!symbol->GetUltimate().attrs().test(semantics::Attr::OPTIONAL)) {
messages.Say(arg ? arg->sourceLocation() : messages.at(),
"Argument of PRESENT() must be the name of a whole OPTIONAL dummy argument"_err_en_US);
}
Expand Down
15 changes: 8 additions & 7 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2036,20 +2036,21 @@ void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) {
void OmpAttributeVisitor::Post(const parser::Name &name) {
auto *symbol{name.symbol};
auto IsPrivatizable = [](const Symbol *sym) {
auto *misc{sym->detailsIf<MiscDetails>()};
return !IsProcedure(*sym) && !IsNamedConstant(*sym) &&
!sym->owner().IsDerivedType() &&
sym->owner().kind() != Scope::Kind::ImpliedDos &&
!sym->detailsIf<semantics::AssocEntityDetails>() &&
!sym->detailsIf<semantics::NamelistDetails>();
!sym->detailsIf<semantics::NamelistDetails>() &&
(!misc ||
(misc->kind() != MiscDetails::Kind::ComplexPartRe &&
misc->kind() != MiscDetails::Kind::ComplexPartIm &&
misc->kind() != MiscDetails::Kind::KindParamInquiry &&
misc->kind() != MiscDetails::Kind::LenParamInquiry &&
misc->kind() != MiscDetails::Kind::ConstructName));
};

if (symbol && !dirContext_.empty() && GetContext().withinConstruct) {
// Exclude construct-names
if (auto *details{symbol->detailsIf<semantics::MiscDetails>()}) {
if (details->kind() == semantics::MiscDetails::Kind::ConstructName) {
return;
}
}
if (IsPrivatizable(symbol) && !IsObjectWithDSA(*symbol)) {
// TODO: create a separate function to go through the rules for
// predetermined, explicitly determined, and implicitly
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Semantics/OpenMP/complex.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
! RUN: %flang_fc1 -fopenmp -fsyntax-only %s

! Check that using %re/%im inside 'parallel' doesn't cause syntax errors.
subroutine test_complex_re_im
complex :: cc(4) = (1,2)
integer :: i

!$omp parallel do private(cc)
do i = 1, 4
print *, cc(i)%re, cc(i)%im
end do
!$omp end parallel do
end subroutine
9 changes: 9 additions & 0 deletions flang/test/Semantics/OpenMP/present.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
! RUN: %flang_fc1 -fopenmp -fsyntax-only %s

! Check that using 'present' inside 'parallel' doesn't cause syntax errors.
subroutine test_present(opt)
integer, optional :: opt
!$omp parallel
if (present(opt)) print *, "present"
!$omp end parallel
end subroutine
Loading