[flang] [OpenMP] add common block example

Original-commit: flang-compiler/f18@a4c923e848
This commit is contained in:
Jinxin Yang 2019-09-15 23:08:29 -07:00 committed by Jinxin (Brian) Yang
parent 4ca8c5dc5c
commit f3961579ac
3 changed files with 39 additions and 2 deletions

View File

@ -1162,7 +1162,7 @@ void OmpVisitor::ResolveOmpObject(
} else {
Say(designator.source, // 2.15.3
"COMMON block must be declared in the same scoping unit "
"in which the directive or clause appears"_err_en_US);
"in which the OpenMP directive or clause appears"_err_en_US);
}
}
}

View File

@ -156,6 +156,7 @@ set(ERROR_TESTS
null01.f90
omp-resolve01.f90
omp-resolve02.f90
omp-resolve03.f90
omp-symbol01.f90
omp-symbol02.f90
omp-symbol03.f90
@ -293,7 +294,7 @@ foreach(test ${MODFILE_TESTS})
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_modfile.sh ${test} ${F18})
endforeach()
foreach(test ${LABEL_TESTS} ${CANONDO_TESTS} ${DOCONCURRENT_TESTS}
foreach(test ${LABEL_TESTS} ${CANONDO_TESTS} ${DOCONCURRENT_TESTS}
${FORALL_TESTS} ${GETSYMBOLS_TESTS} ${GETDEFINITION_TESTS})
add_test(NAME ${test}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_any.sh ${test} ${F18})

View File

@ -0,0 +1,36 @@
! 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.
!OPTIONS: -fopenmp
! 2.15.3 Although variables in common blocks can be accessed by use association
! or host association, common block names cannot. As a result, a common block
! name specified in a data-sharing attribute clause must be declared to be a
! common block in the same scoping unit in which the data-sharing attribute
! clause appears.
common /c/ a, b
integer a(3), b
A = 1
B = 2
block
!ERROR: COMMON block must be declared in the same scoping unit in which the OpenMP directive or clause appears
!$omp parallel shared(/c/)
a(1:2) = 3
B = 4
!$omp end parallel
end block
print *, a, b
end