Skip to content

[flang][OpenMP] Skip implicit typing for OpenMPDeclarativeConstruct #142415

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
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
5 changes: 5 additions & 0 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,9 +1661,14 @@ class OmpVisitor : public virtual DeclarationVisitor {
}
bool Pre(const parser::OpenMPDeclarativeConstruct &x) {
AddOmpSourceRange(x.source);
// Without skipping implicit typing, declarative constructs
// can implicitly declare variables instead of only using the
// ones already declared in the Fortran sources.
SkipImplicitTyping(true);
return true;
}
void Post(const parser::OpenMPDeclarativeConstruct &) {
SkipImplicitTyping(false);
messageHandler().set_currStmtSource(std::nullopt);
}
bool Pre(const parser::OpenMPDepobjConstruct &x) {
Expand Down
12 changes: 12 additions & 0 deletions flang/test/Semantics/OpenMP/declare-simd-linear.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! Test declare simd with linear clause does not cause an implicit declaration of i

module mod
contains
subroutine test(i)
!$omp declare simd linear(i:1)
implicit none
integer*8 i
i=i+2
end subroutine
end module
2 changes: 0 additions & 2 deletions flang/test/Semantics/OpenMP/linear-clause01.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ subroutine linear_clause_02(arg_01, arg_02)
!$omp declare simd linear(uval(arg_02))
integer, value, intent(in) :: arg_02

!ERROR: The list item 'var' specified without the REF 'linear-modifier' must be of INTEGER type
!ERROR: If the `linear-modifier` is REF or UVAL, the list item 'var' must be a dummy argument without the VALUE attribute
!ERROR: The list item `var` must be a dummy argument
!ERROR: The list item `var` in a LINEAR clause must not be Cray Pointer or a variable with POINTER attribute
!$omp declare simd linear(uval(var))
!ERROR: The type of 'var' has already been implicitly declared
integer, pointer :: var
end subroutine linear_clause_02

Expand Down