Skip to content

Commit

Permalink
[flang] Answer comment: split cannondo new tests
Browse files Browse the repository at this point in the history
Original-commit: flang-compiler/f18@7ebf7f7
Reviewed-on: flang-compiler/f18#552
Tree-same-pre-rewrite: false
  • Loading branch information
jeanPerier committed Jul 10, 2019
1 parent 16cf494 commit 93e0516
Show file tree
Hide file tree
Showing 13 changed files with 448 additions and 119 deletions.
4 changes: 2 additions & 2 deletions flang/lib/semantics/canonicalize-do.cc
Expand Up @@ -33,8 +33,8 @@ class CanonicalizationOfDoLoops {
std::visit(
common::visitors{
[](auto &) {},
// Labels on end-stmt of constructs are accepted by f18 for
// as an extension.
// Labels on end-stmt of constructs are accepted by f18 as an
// extension.
[&](common::Indirection<AssociateConstruct> &associate) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndAssociateStmt>>(
Expand Down
119 changes: 2 additions & 117 deletions flang/test/semantics/canondo07.f90
Expand Up @@ -8,133 +8,18 @@
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
! implied.
! See the License for the specific language governing permissions and
! limitations under the License.

! Error test -- DO loop uses obsolete loop termination statement
! See R1131 and C1131

! RUN: ${F18} -funparse-with-symbols -Mstandard %s 2>&1 | ${FileCheck} %s

module iso_fortran_env
type :: team_type
end type
end

subroutine foo0()
do 1 j=1,2
if (.true.) then
! CHECK: A DO loop should terminate with an END DO or CONTINUE
1 end if
do 2 k=1,2
do i=3,4
print*, i+k
! CHECK: A DO loop should terminate with an END DO or CONTINUE
2 end do
do 3 l=1,2
do 3 m=1,2
select case (l)
case default
print*, "default", m, l
case (1)
print*, "start"
! CHECK: A DO loop should terminate with an END DO or CONTINUE
! CHECK: A DO loop should terminate with an END DO or CONTINUE
3 end select
end subroutine

subroutine foo1()
real :: a(10, 10), b(10, 10) = 1.0
do 4 k=1,2
forall (i = 1:10, j = 1:10, b(i, j) /= 0.0)
a(i, j) = real (i + j - k)
b(i, j) = a(i, j) + b(i, j) * real (i * j)
! CHECK: A DO loop should terminate with an END DO or CONTINUE
4 end forall
end subroutine

subroutine foo2()
real :: a(10, 10), b(10, 10) = 1.0
do 4 k=1,4
where (a<k)
a = a + b
b = a - b
elsewhere
a = a*2
! CHECK: A DO loop should terminate with an END DO or CONTINUE
4 end where
end subroutine

subroutine foo3()
real :: a(10, 10), b(10, 10) = 1.0
do 4 k=1,4
associate (x=>a(k+1, 2*k), y=>b(k, 2*k-1))
x = 4*x*x + x*y -2*y
! CHECK: A DO loop should terminate with an END DO or CONTINUE
4 end associate
end subroutine

subroutine foo4()
real :: a(10, 10), b(10, 10) = 1.0
do 4 k=1,4
block
real b
b = a(k, k)
a(k, k) = k*b
! CHECK: A DO loop should terminate with an END DO or CONTINUE
4 end block
end subroutine

subroutine foo5()
real :: a(10, 10), b(10, 10) = 1.0
do 4 k=1,4
critical
b(k+1, k) = a(k, k+1)
! CHECK: A DO loop should terminate with an END DO or CONTINUE
4 end critical
end subroutine

subroutine foo6(a)
type whatever
class(*), allocatable :: x
end type
type(whatever) :: a(10)
do 4 k=1,10
select type (ax => a(k)%x)
type is (integer)
print*, "integer: ", ax
class default
print*, "not useable"
! CHECK: A DO loop should terminate with an END DO or CONTINUE
4 end select
end subroutine

subroutine foo7(a)
integer :: a(..)
do 4 k=1,10
select rank (a)
rank (0)
a = a+k
rank (1)
a(k) = a(k)+k
rank default
print*, "error"
! CHECK: A DO loop should terminate with an END DO or CONTINUE
4 end select
end subroutine

subroutine foo8()
use :: iso_fortran_env, only : team_type
type(team_type) :: odd_even
do 1 k=1,10
change team (odd_even)
! CHECK: A DO loop should terminate with an END DO or CONTINUE
1 end team
end subroutine

program endDo
do 10 i = 1, 5
! CHECK: A DO loop should terminate with an END DO or CONTINUE
10 print *, "in loop"
end program endDo
38 changes: 38 additions & 0 deletions flang/test/semantics/canondo08.f90
@@ -0,0 +1,38 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

! Error test -- DO loop uses obsolete loop termination statement
! See R1131 and C1133

! By default, this is not an error and label do are rewritten to non-label do.
! A warning is generated with -Mstandard


! RUN: ${F18} -funparse-with-symbols -Mstandard %s 2>&1 | ${FileCheck} %s

! CHECK: end do

! The following CHECK-NOT actively uses the fact that the leading zero of labels
! would be removed in the unparse but not the line linked to warnings. We do
! not want to see label do in the unparse only.
! CHECK-NOT: do [1-9]

! CHECK: A DO loop should terminate with an END DO or CONTINUE

subroutine foo1()
do 01 k=1,2
do i=3,4
print*, i+k
01 end do
end subroutine
37 changes: 37 additions & 0 deletions flang/test/semantics/canondo09.f90
@@ -0,0 +1,37 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

! Error test -- DO loop uses obsolete loop termination statement
! See R1131 and C1133

! By default, this is not an error and label do are rewritten to non-label do.
! A warning is generated with -Mstandard


! RUN: ${F18} -funparse-with-symbols -Mstandard %s 2>&1 | ${FileCheck} %s

! CHECK: end do

! The following CHECK-NOT actively uses the fact that the leading zero of labels
! would be removed in the unparse but not the line linked to warnings. We do
! not want to see label do in the unparse only.
! CHECK-NOT: do [1-9]

! CHECK: A DO loop should terminate with an END DO or CONTINUE

subroutine foo0()
do 01 j=1,2
if (.true.) then
01 end if
end subroutine
42 changes: 42 additions & 0 deletions flang/test/semantics/canondo10.f90
@@ -0,0 +1,42 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

! Error test -- DO loop uses obsolete loop termination statement
! See R1131 and C1133

! By default, this is not an error and label do are rewritten to non-label do.
! A warning is generated with -Mstandard


! RUN: ${F18} -funparse-with-symbols -Mstandard %s 2>&1 | ${FileCheck} %s

! CHECK: end do

! The following CHECK-NOT actively uses the fact that the leading zero of labels
! would be removed in the unparse but not the line linked to warnings. We do
! not want to see label do in the unparse only.
! CHECK-NOT: do [1-9]

! CHECK: A DO loop should terminate with an END DO or CONTINUE

subroutine foo2()
do 01 l=1,2
do 01 m=1,2
select case (l)
case default
print*, "default", m, l
case (1)
print*, "start"
01 end select
end subroutine
39 changes: 39 additions & 0 deletions flang/test/semantics/canondo11.f90
@@ -0,0 +1,39 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

! Error test -- DO loop uses obsolete loop termination statement
! See R1131 and C1133

! By default, this is not an error and label do are rewritten to non-label do.
! A warning is generated with -Mstandard


! RUN: ${F18} -funparse-with-symbols -Mstandard %s 2>&1 | ${FileCheck} %s

! CHECK: end do

! The following CHECK-NOT actively uses the fact that the leading zero of labels
! would be removed in the unparse but not the line linked to warnings. We do
! not want to see label do in the unparse only.
! CHECK-NOT: do [1-9]

! CHECK: A DO loop should terminate with an END DO or CONTINUE

subroutine foo3()
real :: a(10, 10), b(10, 10) = 1.0
do 01 k=1,4
associate (x=>a(k+1, 2*k), y=>b(k, 2*k-1))
x = 4*x*x + x*y -2*y
01 end associate
end subroutine
40 changes: 40 additions & 0 deletions flang/test/semantics/canondo12.f90
@@ -0,0 +1,40 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

! Error test -- DO loop uses obsolete loop termination statement
! See R1131 and C1133

! By default, this is not an error and label do are rewritten to non-label do.
! A warning is generated with -Mstandard

! RUN: ${F18} -funparse-with-symbols -Mstandard %s 2>&1 | ${FileCheck} %s

! CHECK: end do

! The following CHECK-NOT actively uses the fact that the leading zero of labels
! would be removed in the unparse but not the line linked to warnings. We do
! not want to see label do in the unparse only.
! CHECK-NOT: do [1-9]

! CHECK: A DO loop should terminate with an END DO or CONTINUE

subroutine foo4()
real :: a(10, 10), b(10, 10) = 1.0
do 01 k=1,4
block
real b
b = a(k, k)
a(k, k) = k*b
01 end block
end subroutine
38 changes: 38 additions & 0 deletions flang/test/semantics/canondo13.f90
@@ -0,0 +1,38 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

! Error test -- DO loop uses obsolete loop termination statement
! See R1131 and C1133

! By default, this is not an error and label do are rewritten to non-label do.
! A warning is generated with -Mstandard

! RUN: ${F18} -funparse-with-symbols -Mstandard %s 2>&1 | ${FileCheck} %s

! CHECK: end do

! The following CHECK-NOT actively uses the fact that the leading zero of labels
! would be removed in the unparse but not the line linked to warnings. We do
! not want to see label do in the unparse only.
! CHECK-NOT: do [1-9]

! CHECK: A DO loop should terminate with an END DO or CONTINUE

subroutine foo5()
real :: a(10, 10), b(10, 10) = 1.0
do 01 k=1,4
critical
b(k+1, k) = a(k, k+1)
01 end critical
end subroutine

0 comments on commit 93e0516

Please sign in to comment.