[llvm-branch-commits] [OpenMP] Add graph_id/graph_reset tests (PR #194049)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 24 13:54:58 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Julian Brown (jtb20)

<details>
<summary>Changes</summary>

Assisted-By: Codex with gpt-5.3

commit-id:9545b560


---
Full diff: https://github.com/llvm/llvm-project/pull/194049.diff


2 Files Affected:

- (added) clang/test/OpenMP/taskgraph_clauses_ast_print.cpp (+94) 
- (added) clang/test/OpenMP/taskgraph_clauses_messages.cpp (+36) 


``````````diff
diff --git a/clang/test/OpenMP/taskgraph_clauses_ast_print.cpp b/clang/test/OpenMP/taskgraph_clauses_ast_print.cpp
new file mode 100644
index 0000000000000..8ac721634380a
--- /dev/null
+++ b/clang/test/OpenMP/taskgraph_clauses_ast_print.cpp
@@ -0,0 +1,94 @@
+// Check no warnings/errors
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Check AST and unparsing
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump  %s | FileCheck %s --check-prefix=DUMP
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+// Check same results after serialization round-trip
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-print    %s | FileCheck %s --check-prefix=PRINT
+
+#ifndef HEADER
+#define HEADER
+
+void taskgraph_clauses() {
+  int A = 1;
+
+  // --- graph_id clause ---
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_idClause
+  // DUMP-NEXT: IntegerLiteral {{.*}} 'int' 0
+  // PRINT: #pragma omp taskgraph graph_id(0)
+  #pragma omp taskgraph graph_id(0)
+  {}
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_idClause
+  // DUMP-NEXT: IntegerLiteral {{.*}} 'int' 42
+  // PRINT: #pragma omp taskgraph graph_id(42)
+  #pragma omp taskgraph graph_id(42)
+  {}
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_idClause
+  // DUMP: BinaryOperator {{.*}} 'int' '+'
+  // DUMP-NEXT: ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
+  // DUMP-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'A' 'int'
+  // DUMP-NEXT: IntegerLiteral {{.*}} 'int' 10
+  // PRINT: #pragma omp taskgraph graph_id(A + 10)
+  #pragma omp taskgraph graph_id(A + 10)
+  {}
+
+  // --- graph_reset clause ---
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_resetClause
+  // DUMP-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false
+  // PRINT: #pragma omp taskgraph graph_reset(false)
+  #pragma omp taskgraph graph_reset(false)
+  {}
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_resetClause
+  // DUMP-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true
+  // PRINT: #pragma omp taskgraph graph_reset(true)
+  #pragma omp taskgraph graph_reset(true)
+  {}
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_resetClause
+  // DUMP-NEXT: BinaryOperator {{.*}} 'bool' '>'
+  // DUMP-NEXT: ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
+  // DUMP-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'A' 'int'
+  // DUMP-NEXT: IntegerLiteral {{.*}} 'int' 5
+  // PRINT: #pragma omp taskgraph graph_reset(A > 5)
+  #pragma omp taskgraph graph_reset(A > 5)
+  {}
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_resetClause
+  // PRINT: #pragma omp taskgraph graph_reset
+  #pragma omp taskgraph graph_reset
+  {}
+
+  // --- Combinations using both clauses ---
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_idClause
+  // DUMP: OMPGraph_resetClause
+  // PRINT: #pragma omp taskgraph graph_id(1) graph_reset(true)
+  #pragma omp taskgraph graph_id(1) graph_reset(true)
+  {}
+
+  // DUMP: OMPTaskgraphDirective
+  // DUMP: OMPGraph_resetClause
+  // DUMP: OMPGraph_idClause
+  // PRINT: #pragma omp taskgraph graph_reset(false) graph_id(2)
+  #pragma omp taskgraph graph_reset(false) graph_id(2)
+  {}
+}
+#endif
diff --git a/clang/test/OpenMP/taskgraph_clauses_messages.cpp b/clang/test/OpenMP/taskgraph_clauses_messages.cpp
new file mode 100644
index 0000000000000..0327f52475d98
--- /dev/null
+++ b/clang/test/OpenMP/taskgraph_clauses_messages.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -verify=expected,omp51 -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -verify=expected,omp60 -fsyntax-only %s
+
+// Tests that the 'graph_id' and 'graph_reset' clauses are accepted in OpenMP 6.0
+// and rejected in prior versions on the 'taskgraph' directive. Also tests
+// duplicate-clause and invalid-condition diagnostics.
+
+void foo() {}
+
+void taskgraph_clauses_messages() {
+  int A = 1;
+
+  // Basic version error tests.
+  #pragma omp taskgraph graph_id(0) // omp51-error {{unexpected OpenMP clause 'graph_id' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP directive '#pragma omp taskgraph'}}
+  {}
+
+  #pragma omp taskgraph graph_reset(true) // omp51-error {{unexpected OpenMP clause 'graph_reset' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP directive '#pragma omp taskgraph'}}
+  {}
+
+  // Same, without argument.
+  #pragma omp taskgraph graph_reset // omp51-error {{unexpected OpenMP clause 'graph_reset' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP directive '#pragma omp taskgraph'}}
+  {}
+
+  // Duplicate clause tests (OMP 6.0 only; in OMP 5.1 both are unexpected).
+  #pragma omp taskgraph graph_id(0) graph_id(1) // omp51-error {{unexpected OpenMP clause 'graph_id' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP clause 'graph_id' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP directive '#pragma omp taskgraph'}} expected-error {{directive '#pragma omp taskgraph' cannot contain more than one 'graph_id' clause}}
+  {}
+
+  #pragma omp taskgraph graph_reset(true) graph_reset(false) // omp51-error {{unexpected OpenMP clause 'graph_reset' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP clause 'graph_reset' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP directive '#pragma omp taskgraph'}} expected-error {{directive '#pragma omp taskgraph' cannot contain more than one 'graph_reset' clause}}
+  {}
+
+  #pragma omp taskgraph graph_id(foo()) // omp51-error {{unexpected OpenMP clause 'graph_id' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP directive '#pragma omp taskgraph'}} omp60-error {{expression must have integral or unscoped enumeration type, not 'void'}}
+  {}
+
+  #pragma omp taskgraph graph_reset(foo()) // omp51-error {{unexpected OpenMP clause 'graph_reset' in directive '#pragma omp taskgraph'}} omp51-error {{unexpected OpenMP directive '#pragma omp taskgraph'}} omp60-error {{value of type 'void' is not contextually convertible to 'bool'}}
+  {}
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/194049


More information about the llvm-branch-commits mailing list