-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][openacc] Make OpenACC block construct parse errors less verbose. #131042
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
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0d69f83
ACC token and context duplication fixed
akuhlens ce39b42
add more descriptive error message and remove newlines
akuhlens acc06e8
back out mistake in constructEndStmtRecovery
akuhlens af72c8e
add recovery to openacc block parser
akuhlens 4ddd177
clean-up
akuhlens 58229d7
fix off by one error in position
akuhlens 990e905
addressing feedback
akuhlens b805e5e
update expected sentinel message
akuhlens 727a977
addressing TODOs in comments
akuhlens 5e75f73
clang-format
akuhlens 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
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
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
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,199 @@ | ||
! RUN: not %flang_fc1 -fsyntax-only -fopenacc %s 2>&1 | FileCheck %s | ||
program acc_data_test | ||
implicit none | ||
integer :: a(100), b(100), c(100), d(100) | ||
integer :: i, s ! FIXME: if s is named sum you get semantic errors. | ||
|
||
! Positive tests | ||
|
||
! Basic data construct in program body | ||
!$acc data copy(a, b) create(c) | ||
a = 1 | ||
b = 2 | ||
c = a + b | ||
!$acc end data | ||
print *, "After first data region" | ||
|
||
! Data construct within IF block | ||
if (.true.) then | ||
!$acc data copyout(a) | ||
a = a + 1 | ||
!$acc end data | ||
print *, "Inside if block" | ||
end if | ||
|
||
! Data construct within DO loop | ||
do i = 1, 10 | ||
!$acc data present(a) | ||
a(i) = a(i) * 2 | ||
!$acc end data | ||
print *, "Loop iteration", i | ||
end do | ||
|
||
! Nested data constructs | ||
!$acc data copyin(a) | ||
s = 0 | ||
!$acc data copy(s) | ||
s = s + 1 | ||
!$acc end data | ||
print *, "After nested data" | ||
!$acc end data | ||
|
||
! Negative tests | ||
! Basic data construct in program body | ||
!$acc data copy(a, b) create(d) bogus() | ||
!CHECK: acc-data-statement.f90: | ||
!CHECK-SAME: error: expected end of OpenACC directive | ||
!CHECK-NEXT: !$acc data copy(a, b) create(d) bogus() | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data copy(a, b) create(d) bogus() | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: execution part | ||
!CHECK-NEXT: !$acc data copy(a, b) create(c) | ||
!CHECK-NEXT: ^ | ||
a = 1 | ||
b = 2 | ||
d = a + b | ||
! !$acc end data | ||
print *, "After first data region" | ||
|
||
! Data construct within IF block | ||
if (.true.) then | ||
!$acc data copyout(a) | ||
a = a + 1 | ||
! !$acc end data | ||
print *, "Inside if block" | ||
!CHECK: acc-data-statement.f90: | ||
!CHECK-SAME: error: expected OpenACC end block directive | ||
!CHECK-NEXT: end if | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data copyout(a) | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: IF construct | ||
!CHECK-NEXT: if (.true.) then | ||
!CHECK-NEXT: ^ | ||
end if | ||
|
||
! Data construct within DO loop | ||
do i = 1, 10 | ||
!$acc data present(a) | ||
a(i) = a(i) * 2 | ||
! !$acc end data | ||
print *, "Loop iteration", i | ||
!CHECK: acc-data-statement.f90: | ||
!CHECK-SAME: error: expected OpenACC end block directive | ||
!CHECK-NEXT: end do | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data present(a) | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: DO construct | ||
!CHECK-NEXT: do i = 1, 10 | ||
!CHECK-NEXT: ^ | ||
end do | ||
|
||
! Nested data constructs | ||
!$acc data copyin(a) | ||
s = 0 | ||
!$acc data copy(s) | ||
s = s + 1 | ||
! !$acc end data | ||
print *, "After nested data" | ||
!$acc end data I forgot to comment this out. | ||
!CHECK: acc-data-statement.f90: | ||
!CHECK-SAME: error: expected end of OpenACC directive | ||
!CHECK-NEXT: !$acc end data I forgot to comment this out. | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data copy(s) | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data copyin(a) | ||
!CHECK-NEXT: ^ | ||
print *, "Program finished" | ||
|
||
!CHECK: acc-data-statement.f90: | ||
!CHECK-SAME: error: expected OpenACC end block directive | ||
!CHECK-NEXT: contains | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data copyin(a) | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data copy(a, b) create(d) bogus() | ||
!CHECK-NEXT: ^ | ||
!CHECK: acc-data-statement.f90: | ||
!CHECK-SAME: error: expected OpenACC end block directive | ||
!CHECK-NEXT: contains | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: $acc data copy(a, b) create(d) bogus() | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: execution part | ||
!CHECK-NEXT: !$acc data copy(a, b) create(c) | ||
!CHECK-NEXT: ^ | ||
contains | ||
subroutine positive_process_array(x) | ||
integer, intent(inout) :: x(:) | ||
|
||
! Data construct in subroutine | ||
!$acc data copy(x) | ||
x = x + 1 | ||
!$acc end data | ||
print *, "Subroutine finished" | ||
end subroutine | ||
|
||
function positive_compute_sum(x) result(total) | ||
integer, intent(in) :: x(:) | ||
integer :: total | ||
|
||
! Data construct in function | ||
!$acc data copyin(x) copy(total) | ||
total = sum(x) | ||
!$acc end data | ||
print *, "Function finished" | ||
end function | ||
|
||
subroutine negative_process_array(x) | ||
integer, intent(inout) :: x(:) | ||
|
||
! Data construct in subroutine | ||
!$acc data copy(x) | ||
x = x + 1 | ||
! !$acc end data | ||
print *, "Subroutine finished" | ||
!CHECK: acc-data-statement.f90: | ||
!CHECK-SAME: error: expected OpenACC end block directive | ||
!CHECK-NEXT: end subroutine | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data copy(x) | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: SUBROUTINE subprogram | ||
!CHECK-NEXT: subroutine negative_process_array(x) | ||
!CHECK-NEXT: ^ | ||
end subroutine | ||
|
||
function negative_compute_sum(x) result(total) | ||
integer, intent(in) :: x(:) | ||
integer :: total | ||
total = sum(x) | ||
! Data construct in function | ||
!$acc data copyin(x) copy(total) | ||
total = total + x | ||
! !$acc end data | ||
print *, "Function finished" | ||
!CHECK: acc-data-statement.f90: | ||
!CHECK-SAME: error: expected OpenACC end block directive | ||
!CHECK-NEXT: end function | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: OpenACC construct | ||
!CHECK-NEXT: !$acc data copyin(x) copy(total) | ||
!CHECK-NEXT: ^ | ||
!CHECK-NEXT: in the context: execution part | ||
!CHECK-NEXT: total = sum(x) | ||
!CHECK-NEXT: ^ | ||
end function | ||
end program acc_data_test |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.