[Openmp-commits] [PATCH] D57615: [AST][OpenMP] OpenMP master Construct contains Structured block

Roman Lebedev via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Feb 1 13:05:15 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.

Much like `single` construct (D57594 <https://reviews.llvm.org/D57594>):

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

- The `master` construct specifies a **structured block** that is executed by the master thread of the team.
- Restrictions • A throw executed inside a `master` region must cause execution to resume within the same `master` region, and the same thread that threw the exception must catch it


Repository:
  rC Clang

https://reviews.llvm.org/D57615

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


Index: test/AST/ast-dump-openmp-master.cpp
===================================================================
--- /dev/null
+++ test/AST/ast-dump-openmp-master.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 master() {
+#pragma omp master
+  {
+  }
+}
+
+// CHECK: `-FunctionDecl
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT:     `-OMPMasterDirective
+// 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
@@ -6050,6 +6050,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();
 
   return OMPMasterDirective::Create(Context, StartLoc, EndLoc, AStmt);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57615.184826.patch
Type: text/x-patch
Size: 1410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190201/724d44b0/attachment.bin>


More information about the Openmp-commits mailing list