Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / declare_reduction_ast_print.c
blob74c28b3219f5161d76bf730ad670a7a75ffcf09d
1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
5 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
8 // expected-no-diagnostics
10 #ifndef HEADER
11 #define HEADER
13 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
14 // CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in){{$}}
15 // CHECK-NEXT: #pragma omp declare reduction (+ : char : omp_out *= omp_in)
17 #pragma omp declare reduction(fun : float : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
18 // CHECK: #pragma omp declare reduction (fun : float : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
20 // CHECK: struct SSS {
21 struct SSS {
22 int field;
23 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
24 // CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in)
25 // CHECK-NEXT: #pragma omp declare reduction (+ : char : omp_out *= omp_in)
27 // CHECK: };
29 void init(struct SSS *priv, struct SSS orig);
31 #pragma omp declare reduction(fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
32 // CHECK: #pragma omp declare reduction (fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
34 // CHECK: int main(void) {
35 int main(void) {
36 #pragma omp declare reduction(fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
37 // CHECK: #pragma omp declare reduction (fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
39 #pragma omp declare reduction(fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
40 // CHECK: #pragma omp declare reduction (fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
42 return 0;
44 // CHECK: }
46 #pragma omp declare reduction(mymin:int \
47 : omp_out = omp_out > omp_in ? omp_in : omp_out) \
48 initializer(omp_priv = 2147483647)
50 #pragma omp declare reduction(mymin \
51 : struct SSS \
52 : omp_out = omp_out.field > omp_in.field ? omp_in : omp_out)
54 int foo(int argc, char **argv) {
55 int x;
56 struct SSS ss;
57 #pragma omp parallel for reduction(mymin : x, ss)
58 for (int i = 0; i < 1000; i++)
60 return 0;
63 // CHECK: #pragma omp parallel for reduction(mymin: x,ss)
64 #endif