[Openmp-commits] [PATCH] D57594: [AST][OpenMP] OpenMP single Construct contains Structured block

Roman Lebedev via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Feb 1 09:36:27 PST 2019


lebedev.ri created this revision.
lebedev.ri added reviewers: ABataev, OpenMP.
lebedev.ri added projects: clang, OpenMP.
Herald added subscribers: openmp-commits, guansong.

`OpenMP Application Programming Interface Version 5.0 November 2018` <https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf>, `2.8.2 single Construct`, starting with page 89:

- The `single` construct specifies that the associated **structured block** is executed by only one of the threads in the team (not necessarily the master thread), in the context of its implicit task.
- Restrictions • A throw executed inside a `single` region must cause execution to resume within the same `single` region, and the same thread that threw the exception must catch it.


Repository:
  rC Clang

https://reviews.llvm.org/D57594

Files:
  lib/Sema/SemaOpenMP.cpp
  test/AST/ast-dump-openmp-single.cpp


Index: test/AST/ast-dump-openmp-single.cpp
===================================================================
--- /dev/null
+++ test/AST/ast-dump-openmp-single.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-dump %s | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-dump %s | FileCheck %s
+// expected-no-diagnostics
+
+void single() {
+#pragma omp single
+  {
+  }
+}
+
+// CHECK:`-FunctionDecl
+// CHECK-NEXT:  `-CompoundStmt
+// CHECK-NEXT:    `-OMPSingleDirective
+// CHECK-NEXT:      `-CapturedStmt
+// CHECK-NEXT:        `-CapturedDecl {{.*}} nothrow
+// CHECK-NEXT:          |-CompoundStmt
+// CHECK-NEXT:          `-ImplicitParamDecl
Index: lib/Sema/SemaOpenMP.cpp
===================================================================
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6013,6 +6013,13 @@
 
   assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
 
+  // 1.2.2 OpenMP Language Terminology
+  // Structured block - An executable statement with a single entry at the
+  // top and a single exit at the bottom.
+  // The point of exit cannot be a branch out of the structured block.
+  // longjmp() and throw() must not violate the entry/exit criteria.
+  cast<CapturedStmt>(AStmt)->getCapturedDecl()->setNothrow();
+
   setFunctionHasBranchProtectedScope();
 
   // OpenMP [2.7.3, single Construct, Restrictions]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57594.184772.patch
Type: text/x-patch
Size: 1384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190201/ced77841/attachment.bin>


More information about the Openmp-commits mailing list