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);


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);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to