2015-05-20 12:24:19 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2014-07-22 18:10:35 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
|
|
|
|
|
|
|
template <class T>
|
2014-07-23 15:46:59 +08:00
|
|
|
T foo(T argc) {
|
2014-07-24 14:46:57 +08:00
|
|
|
T b = T();
|
2014-07-23 15:46:59 +08:00
|
|
|
T a = T();
|
2014-07-22 18:10:35 +08:00
|
|
|
#pragma omp atomic
|
|
|
|
a++;
|
2014-07-23 10:27:21 +08:00
|
|
|
#pragma omp atomic read
|
2014-07-23 15:46:59 +08:00
|
|
|
a = argc;
|
|
|
|
#pragma omp atomic write
|
|
|
|
a = argc + argc;
|
2014-07-23 18:25:33 +08:00
|
|
|
#pragma omp atomic update
|
|
|
|
a = a + argc;
|
2014-07-24 14:46:57 +08:00
|
|
|
#pragma omp atomic capture
|
|
|
|
a = b++;
|
|
|
|
#pragma omp atomic capture
|
|
|
|
{
|
|
|
|
a = b;
|
|
|
|
b++;
|
|
|
|
}
|
2014-07-24 16:55:34 +08:00
|
|
|
#pragma omp atomic seq_cst
|
|
|
|
a++;
|
|
|
|
#pragma omp atomic read seq_cst
|
|
|
|
a = argc;
|
|
|
|
#pragma omp atomic seq_cst write
|
|
|
|
a = argc + argc;
|
|
|
|
#pragma omp atomic update seq_cst
|
|
|
|
a = a + argc;
|
|
|
|
#pragma omp atomic seq_cst capture
|
|
|
|
a = b++;
|
|
|
|
#pragma omp atomic capture seq_cst
|
|
|
|
{
|
|
|
|
a = b;
|
|
|
|
b++;
|
|
|
|
}
|
2014-07-22 18:10:35 +08:00
|
|
|
return T();
|
|
|
|
}
|
|
|
|
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: T a = T();
|
2014-07-22 18:10:35 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic
|
|
|
|
// CHECK-NEXT: a++;
|
2014-07-23 10:27:21 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic read
|
2014-07-23 15:46:59 +08:00
|
|
|
// CHECK-NEXT: a = argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic write
|
|
|
|
// CHECK-NEXT: a = argc + argc;
|
2014-07-23 18:25:33 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic update
|
|
|
|
// CHECK-NEXT: a = a + argc;
|
2014-07-24 14:46:57 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic capture
|
|
|
|
// CHECK-NEXT: a = b++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic capture
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: a = b;
|
|
|
|
// CHECK-NEXT: b++;
|
|
|
|
// CHECK-NEXT: }
|
2014-07-24 16:55:34 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst
|
|
|
|
// CHECK-NEXT: a++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic read seq_cst
|
|
|
|
// CHECK-NEXT: a = argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst write
|
|
|
|
// CHECK-NEXT: a = argc + argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic update seq_cst
|
|
|
|
// CHECK-NEXT: a = a + argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst capture
|
|
|
|
// CHECK-NEXT: a = b++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic capture seq_cst
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: a = b;
|
|
|
|
// CHECK-NEXT: b++;
|
|
|
|
// CHECK-NEXT: }
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: int a = int();
|
2014-07-22 18:10:35 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic
|
|
|
|
// CHECK-NEXT: a++;
|
2014-07-23 10:27:21 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic read
|
2014-07-23 15:46:59 +08:00
|
|
|
// CHECK-NEXT: a = argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic write
|
|
|
|
// CHECK-NEXT: a = argc + argc;
|
2014-07-23 18:25:33 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic update
|
|
|
|
// CHECK-NEXT: a = a + argc;
|
2014-07-24 14:46:57 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic capture
|
|
|
|
// CHECK-NEXT: a = b++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic capture
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: a = b;
|
|
|
|
// CHECK-NEXT: b++;
|
|
|
|
// CHECK-NEXT: }
|
2014-07-24 16:55:34 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst
|
|
|
|
// CHECK-NEXT: a++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic read seq_cst
|
|
|
|
// CHECK-NEXT: a = argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst write
|
|
|
|
// CHECK-NEXT: a = argc + argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic update seq_cst
|
|
|
|
// CHECK-NEXT: a = a + argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst capture
|
|
|
|
// CHECK-NEXT: a = b++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic capture seq_cst
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: a = b;
|
|
|
|
// CHECK-NEXT: b++;
|
|
|
|
// CHECK-NEXT: }
|
2014-07-22 18:10:35 +08:00
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2014-07-24 14:46:57 +08:00
|
|
|
int b = 0;
|
2014-07-23 15:46:59 +08:00
|
|
|
int a = 0;
|
|
|
|
// CHECK: int a = 0;
|
2014-07-22 18:10:35 +08:00
|
|
|
#pragma omp atomic
|
|
|
|
a++;
|
2014-07-23 10:27:21 +08:00
|
|
|
#pragma omp atomic read
|
|
|
|
a = argc;
|
2014-07-23 15:46:59 +08:00
|
|
|
#pragma omp atomic write
|
|
|
|
a = argc + argc;
|
2014-07-23 18:25:33 +08:00
|
|
|
#pragma omp atomic update
|
|
|
|
a = a + argc;
|
2014-07-24 14:46:57 +08:00
|
|
|
#pragma omp atomic capture
|
|
|
|
a = b++;
|
|
|
|
#pragma omp atomic capture
|
|
|
|
{
|
|
|
|
a = b;
|
|
|
|
b++;
|
|
|
|
}
|
2014-07-24 16:55:34 +08:00
|
|
|
#pragma omp atomic seq_cst
|
|
|
|
a++;
|
|
|
|
#pragma omp atomic read seq_cst
|
|
|
|
a = argc;
|
|
|
|
#pragma omp atomic seq_cst write
|
|
|
|
a = argc + argc;
|
|
|
|
#pragma omp atomic update seq_cst
|
|
|
|
a = a + argc;
|
|
|
|
#pragma omp atomic seq_cst capture
|
|
|
|
a = b++;
|
|
|
|
#pragma omp atomic capture seq_cst
|
|
|
|
{
|
|
|
|
a = b;
|
|
|
|
b++;
|
|
|
|
}
|
2014-07-22 18:10:35 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic
|
|
|
|
// CHECK-NEXT: a++;
|
2014-07-23 10:27:21 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic read
|
|
|
|
// CHECK-NEXT: a = argc;
|
2014-07-23 15:46:59 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic write
|
|
|
|
// CHECK-NEXT: a = argc + argc;
|
2014-07-23 18:25:33 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic update
|
|
|
|
// CHECK-NEXT: a = a + argc;
|
2014-07-24 14:46:57 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic capture
|
|
|
|
// CHECK-NEXT: a = b++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic capture
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: a = b;
|
|
|
|
// CHECK-NEXT: b++;
|
|
|
|
// CHECK-NEXT: }
|
2014-07-24 16:55:34 +08:00
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst
|
|
|
|
// CHECK-NEXT: a++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic read seq_cst
|
|
|
|
// CHECK-NEXT: a = argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst write
|
|
|
|
// CHECK-NEXT: a = argc + argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic update seq_cst
|
|
|
|
// CHECK-NEXT: a = a + argc;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic seq_cst capture
|
|
|
|
// CHECK-NEXT: a = b++;
|
|
|
|
// CHECK-NEXT: #pragma omp atomic capture seq_cst
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: a = b;
|
|
|
|
// CHECK-NEXT: b++;
|
|
|
|
// CHECK-NEXT: }
|
2014-07-22 18:10:35 +08:00
|
|
|
return foo(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|