-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] Allow OpenMP declarations before type declarations #112414
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
! RUN: %flang -fsyntax-only -fopenmp %s 2>&1 | ||
|
||
! Check that OpenMP declarative directives can be used with objects that have | ||
! an incomplete type. | ||
|
||
subroutine test_decl | ||
! OMPv5.2 5.2 threadprivate | ||
! OMPv5.2 6.5 allocate | ||
implicit none | ||
save :: x1, y1 | ||
!$omp threadprivate(x1) | ||
!$omp allocate(y1) | ||
integer :: x1, y1 | ||
|
||
! OMPv5.2 7.7 declare-simd | ||
external :: simd_func | ||
!$omp declare simd(simd_func) | ||
logical :: simd_func | ||
|
||
! OMPv5.2 7.8.1 declare-target | ||
allocatable :: j | ||
!$omp declare target(j) | ||
save :: j | ||
real(kind=8) :: j(:) | ||
|
||
! OMPv5.2 5.5.11 declare-reduction - crashes | ||
!external :: my_add_red | ||
!!$omp declare reduction(my_add_red : integer : my_add_red(omp_out, omp_in)) & | ||
!!$omp& initializer(omp_priv=0) | ||
!integer :: my_add_red | ||
end subroutine | ||
|
||
subroutine test_decl2 | ||
save x1, y1 | ||
!$omp threadprivate(x1) | ||
!$omp allocate(y1) | ||
integer :: x1, y1 | ||
|
||
! implicit decl | ||
!$omp threadprivate(x2) | ||
!$omp allocate(y2) | ||
save x2, y2 | ||
end subroutine | ||
|
||
module m1 | ||
! implicit decl | ||
!$omp threadprivate(x, y, z) | ||
integer :: y | ||
real :: z | ||
|
||
contains | ||
subroutine sub | ||
!$omp parallel copyin(x, y, z) | ||
!$omp end parallel | ||
end subroutine | ||
end module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does
deferImplicitTyping_
need to be set here? What is the difference betweendefer
andskip
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
deferImplicitTyping_
is set, checks for explicit types in contexts that require it (e.g.implicit none
) are performed later. Not setting it would result in errors, as in the following example:error: No explicit type declared for 'x1'
This happens because there is a data reference to
x1
, in!$omp threadprivate(x1)
, which in other cases would require its explicit type to have already been specified.The
skipImplicitTyping_
flag handles another case. The idea is that it skips setting implicit types. Even whendeferImplicitTyping_
is set, the implicit type of an entity is set when it is referenced, as in the example above. The problem is that, if the type that is declared after the reference doesn't match the previous implicit type, an error is reported.In the example above, with
skipImplicitTyping_ = false
,x1
type is set toreal
in thethreadprivate
line, which doesn't match theinteger
type specified later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for explaining!