PR #101009 exposed a semantic check issue with OPTIONAL dummy arguments. Another issue occurred when using %{re,im,len,kind}, as these also need to be skipped when handling variables with implicitly defined DSAs. These issues were found by Fujitsu testsuite.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
13
flang/test/Semantics/OpenMP/complex.f90
Normal file
13
flang/test/Semantics/OpenMP/complex.f90
Normal file
@@ -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
flang/test/Semantics/OpenMP/present.f90
Normal file
9
flang/test/Semantics/OpenMP/present.f90
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user