summaryrefslogtreecommitdiffstats
path: root/test/OpenMP
diff options
context:
space:
mode:
Diffstat (limited to 'test/OpenMP')
-rw-r--r--test/OpenMP/linking.c16
-rw-r--r--test/OpenMP/no_option.c6
-rw-r--r--test/OpenMP/no_option_no_warn.c6
-rw-r--r--test/OpenMP/openmp_common.c9
-rw-r--r--test/OpenMP/option_warn.c5
-rw-r--r--test/OpenMP/predefined_macro.c34
-rw-r--r--test/OpenMP/threadprivate_ast_print.cpp43
-rw-r--r--test/OpenMP/threadprivate_messages.cpp119
8 files changed, 238 insertions, 0 deletions
diff --git a/test/OpenMP/linking.c b/test/OpenMP/linking.c
new file mode 100644
index 0000000..31fd57d
--- /dev/null
+++ b/test/OpenMP/linking.c
@@ -0,0 +1,16 @@
+// Test the that the driver produces reasonable linker invocations with
+// -fopenmp.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -fopenmp -target i386-unknown-linux \
+// RUN: | FileCheck --check-prefix=CHECK-LD-32 %s
+// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-32: "-lgomp" "-lrt" "-lgcc"
+// CHECK-LD-32: "-lpthread" "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -fopenmp -target x86_64-unknown-linux \
+// RUN: | FileCheck --check-prefix=CHECK-LD-64 %s
+// CHECK-LD-64: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-64: "-lgomp" "-lrt" "-lgcc"
+// CHECK-LD-64: "-lpthread" "-lc"
diff --git a/test/OpenMP/no_option.c b/test/OpenMP/no_option.c
new file mode 100644
index 0000000..4acc8d0
--- /dev/null
+++ b/test/OpenMP/no_option.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -verify -o - %s
+// expected-no-diagnostics
+
+int a;
+#pragma omp threadprivate(a,b)
+#pragma omp parallel
diff --git a/test/OpenMP/no_option_no_warn.c b/test/OpenMP/no_option_no_warn.c
new file mode 100644
index 0000000..c989991
--- /dev/null
+++ b/test/OpenMP/no_option_no_warn.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -verify -Wno-source-uses-openmp -o - %s
+// expected-no-diagnostics
+
+int a;
+#pragma omp threadprivate(a,b)
+#pragma omp parallel
diff --git a/test/OpenMP/openmp_common.c b/test/OpenMP/openmp_common.c
new file mode 100644
index 0000000..ca5d89a
--- /dev/null
+++ b/test/OpenMP/openmp_common.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+#pragma omp // expected-error {{expected an OpenMP directive}}
+#pragma omp unknown_directive // expected-error {{expected an OpenMP directive}}
+
+void foo() {
+#pragma omp // expected-error {{expected an OpenMP directive}}
+#pragma omp unknown_directive // expected-error {{expected an OpenMP directive}}
+}
diff --git a/test/OpenMP/option_warn.c b/test/OpenMP/option_warn.c
new file mode 100644
index 0000000..ddec8e1
--- /dev/null
+++ b/test/OpenMP/option_warn.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -verify -Wsource-uses-openmp -o - %s
+
+int a;
+#pragma omp threadprivate(a,b) // expected-warning {{unexpected '#pragma omp ...' in program}}
+#pragma omp parallel
diff --git a/test/OpenMP/predefined_macro.c b/test/OpenMP/predefined_macro.c
new file mode 100644
index 0000000..cf6c0cc
--- /dev/null
+++ b/test/OpenMP/predefined_macro.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fopenmp -verify -DFOPENMP -o - %s
+// RUN: %clang_cc1 -verify -o - %s
+// expected-no-diagnostics
+#ifdef FOPENMP
+// -fopenmp option is specified
+#ifndef _OPENMP
+#error "No _OPENMP macro is defined with -fopenmp option"
+#elsif _OPENMP != 201107
+#error "_OPENMP has incorrect value"
+#endif //_OPENMP
+#else
+// No -fopenmp option is specified
+#ifdef _OPENMP
+#error "_OPENMP macro is defined without -fopenmp option"
+#endif // _OPENMP
+#endif // FOPENMP
+
+// RUN: %clang_cc1 -fopenmp -verify -DFOPENMP -o - %s
+// RUN: %clang_cc1 -verify -o - %s
+// expected-no-diagnostics
+#ifdef FOPENMP
+// -fopenmp option is specified
+#ifndef _OPENMP
+#error "No _OPENMP macro is defined with -fopenmp option"
+#elsif _OPENMP != 201107
+#error "_OPENMP has incorrect value"
+#endif // _OPENMP
+#else
+// No -fopenmp option is specified
+#ifdef _OPENMP
+#error "_OPENMP macro is defined without -fopenmp option"
+#endif // _OPENMP
+#endif // FOPENMP
+
diff --git a/test/OpenMP/threadprivate_ast_print.cpp b/test/OpenMP/threadprivate_ast_print.cpp
new file mode 100644
index 0000000..deb829e
--- /dev/null
+++ b/test/OpenMP/threadprivate_ast_print.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+// expected-no-diagnostics
+
+struct St{
+ int a;
+};
+
+struct St1{
+ int a;
+ static int b;
+// CHECK: static int b;
+#pragma omp threadprivate(b)
+// CHECK-NEXT: #pragma omp threadprivate(b)
+} d;
+
+int a, b;
+// CHECK: int a;
+// CHECK: int b;
+#pragma omp threadprivate(a)
+// CHECK-NEXT: #pragma omp threadprivate(a)
+#pragma omp threadprivate(d, b)
+// CHECK-NEXT: #pragma omp threadprivate(d,b)
+
+template <class T> T foo() {
+ static T v;
+ #pragma omp threadprivate(v)
+ return v;
+}
+//CHECK: template <class T = int> int foo() {
+//CHECK-NEXT: static int v;
+//CHECK-NEXT: #pragma omp threadprivate(v)
+//CHECK: template <class T> T foo() {
+//CHECK-NEXT: static T v;
+//CHECK-NEXT: #pragma omp threadprivate(v)
+
+int main () {
+ static int a;
+// CHECK: static int a;
+#pragma omp threadprivate(a)
+// CHECK-NEXT: #pragma omp threadprivate(a)
+ a=2;
+ return (foo<int>());
+}
diff --git a/test/OpenMP/threadprivate_messages.cpp b/test/OpenMP/threadprivate_messages.cpp
new file mode 100644
index 0000000..0c448b2
--- /dev/null
+++ b/test/OpenMP/threadprivate_messages.cpp
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 %s
+
+#pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}}
+#pragma omp threadprivate( // expected-error {{expected unqualified-id}}
+#pragma omp threadprivate() // expected-error {{expected unqualified-id}}
+#pragma omp threadprivate(1) // expected-error {{expected unqualified-id}}
+struct CompleteSt{
+ int a;
+};
+
+struct CompleteSt1{
+#pragma omp threadprivate(1) // expected-error {{expected unqualified-id}}
+ int a;
+} d; // expected-note {{forward declaration of 'd'}}
+
+int a; // expected-note {{forward declaration of 'a'}}
+
+#pragma omp threadprivate(a)
+#pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}}
+#pragma omp threadprivate(d, a) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}}
+int foo() { // expected-note {{declared here}}
+ static int l;
+#pragma omp threadprivate(l)) // expected-warning {{extra tokens at end of '#pragma omp threadprivate' are ignored}}
+ return (a);
+}
+
+#pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}}
+#pragma omp threadprivate(d // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}}
+#pragma omp threadprivate(d))
+int x, y;
+#pragma omp threadprivate(x)) // expected-warning {{extra tokens at end of '#pragma omp threadprivate' are ignored}}
+#pragma omp threadprivate(y)), // expected-warning {{extra tokens at end of '#pragma omp threadprivate' are ignored}}
+#pragma omp threadprivate(a,d) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}}
+#pragma omp threadprivate(d.a) // expected-error {{expected unqualified-id}}
+#pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}}
+int foa;
+#pragma omp threadprivate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}}
+#pragma omp threadprivate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}}
+#pragma omp threadprivate (int a=2) // expected-error {{expected unqualified-id}}
+
+struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}}
+
+extern IncompleteSt e;
+#pragma omp threadprivate (e) // expected-error {{a threadprivate variable must not have incomplete type 'IncompleteSt'}}
+
+int &f = a; // expected-note {{forward declaration of 'f'}}
+#pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}}
+
+class Class {
+ private:
+ int a; // expected-note {{declared here}}
+ static int b;
+ Class() : a(0){}
+ public:
+ Class (int aaa) : a(aaa) {}
+#pragma omp threadprivate (b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}}
+} g(10);
+#pragma omp threadprivate (b) // expected-error {{use of undeclared identifier 'b'}}
+#pragma omp threadprivate (Class::b) // expected-error {{expected unqualified-id}}
+#pragma omp threadprivate (g)
+
+namespace ns {
+ int m;
+#pragma omp threadprivate (m)
+}
+#pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}}
+#pragma omp threadprivate (ns::m) // expected-error {{expected unqualified-id}}
+#pragma omp threadprivate (ns:m) // expected-error {{expected unqualified-id}}
+
+const int h = 12;
+const volatile int i = 10;
+#pragma omp threadprivate (h, i)
+
+
+template <class T>
+class TempClass {
+ private:
+ T a;
+ TempClass() : a(){}
+ public:
+ TempClass (T aaa) : a(aaa) {}
+ static T s;
+#pragma omp threadprivate (s)
+};
+#pragma omp threadprivate (s) // expected-error {{use of undeclared identifier 's'}}
+
+static __thread int t; // expected-note {{forward declaration of 't'}}
+#pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}}
+
+int o; // expected-note {{candidate found by name lookup is 'o'}}
+namespace {
+int o; // expected-note {{candidate found by name lookup is '<anonymous namespace>::o'}}
+}
+#pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}}
+
+int main(int argc, char **argv) { // expected-note {{forward declaration of 'argc'}}
+
+ int x, y = argc; // expected-note {{forward declaration of 'y'}}
+ static double d1;
+ static double d2;
+ static double d3; // expected-note {{forward declaration of 'd3'}}
+
+ d.a = a;
+ d2++;
+ ;
+#pragma omp threadprivate(argc+y) // expected-error {{expected unqualified-id}}
+#pragma omp threadprivate(argc,y) // expected-error 2 {{arguments of '#pragma omp threadprivate' must have static storage duration}}
+#pragma omp threadprivate(d2) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd2'}}
+#pragma omp threadprivate(d1)
+ {
+ ++a;d2=0;
+#pragma omp threadprivate(d3) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd3' variable declaration}}
+ }
+#pragma omp threadprivate(d3)
+
+#pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}}
+ return (y);
+#pragma omp threadprivate(d) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd' variable declaration}}
+}
OpenPOWER on IntegriCloud