From f3961579acc39dd598406ca048efef6a334d3e7f Mon Sep 17 00:00:00 2001 From: Jinxin Yang Date: Sun, 15 Sep 2019 23:08:29 -0700 Subject: [PATCH] [flang] [OpenMP] add common block example Original-commit: flang-compiler/f18@a4c923e848bd55adc734808dbc019951610c29e6 --- flang/lib/semantics/resolve-names.cc | 2 +- flang/test/semantics/CMakeLists.txt | 3 ++- flang/test/semantics/omp-resolve03.f90 | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 flang/test/semantics/omp-resolve03.f90 diff --git a/flang/lib/semantics/resolve-names.cc b/flang/lib/semantics/resolve-names.cc index 9e6f14a..e39ebbd 100644 --- a/flang/lib/semantics/resolve-names.cc +++ b/flang/lib/semantics/resolve-names.cc @@ -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); } } } diff --git a/flang/test/semantics/CMakeLists.txt b/flang/test/semantics/CMakeLists.txt index 07f8a22..08a2c73 100644 --- a/flang/test/semantics/CMakeLists.txt +++ b/flang/test/semantics/CMakeLists.txt @@ -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}) diff --git a/flang/test/semantics/omp-resolve03.f90 b/flang/test/semantics/omp-resolve03.f90 new file mode 100644 index 0000000..e476f23 --- /dev/null +++ b/flang/test/semantics/omp-resolve03.f90 @@ -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 -- 2.7.4