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]


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

Reply via email to