diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/OpenMP/allocate_ast_print.cpp | 79 | ||||
-rw-r--r-- | clang/test/OpenMP/allocate_messages.cpp | 149 | ||||
-rw-r--r-- | clang/test/PCH/chain-openmp-allocate.cpp | 36 |
3 files changed, 264 insertions, 0 deletions
diff --git a/clang/test/OpenMP/allocate_ast_print.cpp b/clang/test/OpenMP/allocate_ast_print.cpp new file mode 100644 index 00000000000..bd0a7e89944 --- /dev/null +++ b/clang/test/OpenMP/allocate_ast_print.cpp @@ -0,0 +1,79 @@ +// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin10.6.0 -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10.6.0 -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10.6.0 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print +// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-linux-gnu -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print + +// RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print +// RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-linux-gnu -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp-simd -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp-simd -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print +// expected-no-diagnostics + +#ifndef HEADER +#define HEADER + +struct St{ + int a; +}; + +struct St1{ + int a; + static int b; +// CHECK: static int b; +#pragma omp allocate(b) +// CHECK-NEXT: #pragma omp allocate(St1::b){{$}} +} d; + +int a, b; +// CHECK: int a; +// CHECK: int b; +#pragma omp allocate(a) +#pragma omp allocate(a) +// CHECK-NEXT: #pragma omp allocate(a) +// CHECK-NEXT: #pragma omp allocate(a) +#pragma omp allocate(d, b) +// CHECK-NEXT: #pragma omp allocate(d,b) + +template <class T> +struct ST { + static T m; + #pragma omp allocate(m) +}; + +template <class T> T foo() { + T v; + #pragma omp allocate(v) + v = ST<T>::m; + return v; +} +//CHECK: template <class T> T foo() { +//CHECK-NEXT: T v; +//CHECK-NEXT: #pragma omp allocate(v) +//CHECK: template<> int foo<int>() { +//CHECK-NEXT: int v; +//CHECK-NEXT: #pragma omp allocate(v) + +namespace ns{ + int a; +} +// CHECK: namespace ns { +// CHECK-NEXT: int a; +// CHECK-NEXT: } +#pragma omp allocate(ns::a) +// CHECK-NEXT: #pragma omp allocate(ns::a) + +int main () { + static int a; +// CHECK: static int a; +#pragma omp allocate(a) +// CHECK-NEXT: #pragma omp allocate(a) + a=2; + return (foo<int>()); +} + +extern template int ST<int>::m; +#endif diff --git a/clang/test/OpenMP/allocate_messages.cpp b/clang/test/OpenMP/allocate_messages.cpp new file mode 100644 index 00000000000..2d40f792d1b --- /dev/null +++ b/clang/test/OpenMP/allocate_messages.cpp @@ -0,0 +1,149 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -emit-llvm -o - %s + +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -emit-llvm -o - %s + +#pragma omp allocate // expected-error {{expected '(' after 'allocate'}} +#pragma omp allocate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp allocate() // expected-error {{expected identifier}} +#pragma omp allocate(1) // expected-error {{expected unqualified-id}} +struct CompleteSt { + int a; +}; + +struct CompleteSt1 { +#pragma omp allocate(1) // expected-error {{expected unqualified-id}} + int a; +} d; // expected-note {{'d' defined here}} + +int a; // expected-note {{'a' defined here}} + +#pragma omp allocate(a) +#pragma omp allocate(u) // expected-error {{use of undeclared identifier 'u'}} +#pragma omp allocate(d, a) +int foo() { // expected-note {{declared here}} + static int l; +#pragma omp allocate(l)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}} + return (a); +} + +#pragma omp allocate(a)( +// expected-warning@-1 {{extra tokens at the end of '#pragma omp allocate' are ignored}} +#pragma omp allocate(a)[ // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}} +#pragma omp allocate(a) { // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}} +#pragma omp allocate(a)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}} +#pragma omp allocate(a)] // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}} +#pragma omp allocate(a) } // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}} +#pragma omp allocate a // expected-error {{expected '(' after 'allocate'}} +#pragma omp allocate(d // expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp allocate(d)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}} +int x, y; +#pragma omp allocate(x)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}} +#pragma omp allocate(y)), +// expected-warning@-1 {{extra tokens at the end of '#pragma omp allocate' are ignored}} +#pragma omp allocate(a, d) +#pragma omp allocate(d.a) // expected-error {{expected identifier}} +#pragma omp allocate((float)a) // expected-error {{expected unqualified-id}} +int foa; // expected-note {{'foa' declared here}} +#pragma omp allocate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}} +#pragma omp allocate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}} +#pragma omp allocate(int a = 2) // expected-error {{expected unqualified-id}} + +struct IncompleteSt; + +extern IncompleteSt e; +#pragma omp allocate(e) + +int &f = a; +#pragma omp allocate(f) + +class TestClass { +private: + int a; // expected-note {{declared here}} + static int b; // expected-note {{'b' declared here}} + TestClass() : a(0) {} + +public: + TestClass(int aaa) : a(aaa) {} +#pragma omp allocate(b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}} +} g(10); +#pragma omp allocate(b) // expected-error {{use of undeclared identifier 'b'}} +#pragma omp allocate(TestClass::b) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'TestClass::b' variable declaration}} +#pragma omp allocate(g) + +namespace ns { +int m; +#pragma omp allocate(m, m) +} // namespace ns +#pragma omp allocate(m) // expected-error {{use of undeclared identifier 'm'}} +#pragma omp allocate(ns::m) +#pragma omp allocate(ns \ + : m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} + +const int h = 12; +const volatile int i = 10; +#pragma omp allocate(h, i) + +template <class T> +class TempClass { +private: + T a; + TempClass() : a() {} + +public: + TempClass(T aaa) : a(aaa) {} + static T s; +#pragma omp allocate(s) +}; +#pragma omp allocate(s) // expected-error {{use of undeclared identifier 's'}} + +static __thread int t; +#pragma omp allocate(t) + +// Register "0" is currently an invalid register for global register variables. +// Use "esp" instead of "0". +// register int reg0 __asm__("0"); +register int reg0 __asm__("esp"); +#pragma omp allocate(reg0) + +int o; // expected-note {{candidate found by name lookup is 'o'}} +#pragma omp allocate(o) +namespace { +int o; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}} +#pragma omp allocate(o) +#pragma omp allocate(o) +} // namespace +#pragma omp allocate(o) // expected-error {{reference to 'o' is ambiguous}} +#pragma omp allocate(::o) + +int main(int argc, char **argv) { + + int x, y = argc; + static double d1; + static double d2; + static double d3; // expected-note {{'d3' defined here}} + static double d4; + static TestClass LocalClass(y); +#pragma omp allocate(LocalClass) + + d.a = a; + d2++; + ; +#pragma omp allocate(argc + y) // expected-error {{expected identifier}} +#pragma omp allocate(argc, y) +#pragma omp allocate(d2) +#pragma omp allocate(d1) + { + ++a; + d2 = 0; +#pragma omp allocate(d3) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'd3' variable declaration}} + } +#pragma omp allocate(d3) +label: +#pragma omp allocate(d4) // expected-error {{'#pragma omp allocate' cannot be an immediate substatement}} + +#pragma omp allocate(a) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'a' variable declaration}} + return (y); +#pragma omp allocate(d) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'd' variable declaration}} +} diff --git a/clang/test/PCH/chain-openmp-allocate.cpp b/clang/test/PCH/chain-openmp-allocate.cpp new file mode 100644 index 00000000000..ea529b56ba9 --- /dev/null +++ b/clang/test/PCH/chain-openmp-allocate.cpp @@ -0,0 +1,36 @@ +// no PCH +// RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -ast-print -include %s -include %s %s -o - | FileCheck %s +// with PCH +// RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -ast-print -chain-include %s -chain-include %s %s -o - | FileCheck %s +// no PCH +// RUN: %clang_cc1 -fopenmp -ast-print -include %s -include %s %s -o - | FileCheck %s -check-prefix=CHECK-ALLOC-1 +// RUN: %clang_cc1 -fopenmp -ast-print -include %s -include %s %s -o - | FileCheck %s -check-prefix=CHECK-ALLOC-2 +// with PCH +// RUN: %clang_cc1 -fopenmp -ast-print -chain-include %s -chain-include %s %s -o - | FileCheck %s -check-prefix=CHECK-ALLOC-1 +// RUN: %clang_cc1 -fopenmp -ast-print -chain-include %s -chain-include %s %s -o - | FileCheck %s -check-prefix=CHECK-ALLOC-2 + +#if !defined(PASS1) +#define PASS1 + +int a; +// CHECK: int a; + +#elif !defined(PASS2) +#define PASS2 + +#pragma omp allocate(a) +// CHECK: #pragma omp allocate(a) + +#else + +// CHECK-LABEL: foo +// CHECK-ALLOC-LABEL: foo +int foo() { + return a; + // CHECK: return a; + // CHECK-ALLOC-1: return a; +} + +// CHECK-ALLOC-2: return a; + +#endif |