]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/teams_distribute_parallel_for_simd_num_threads_messages.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / OpenMP / teams_distribute_parallel_for_simd_num_threads_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2
3 void foo() {
4 }
5
6 bool foobool(int argc) {
7   return argc;
8 }
9
10 struct S1; // expected-note {{declared here}}
11
12 template <class T, typename S, int N> // expected-note {{declared here}}
13 T tmain(T argc, S **argv) {
14   T i;
15 #pragma omp target
16 #pragma omp teams distribute parallel for simd num_threads // expected-error {{expected '(' after 'num_threads'}}
17   for (i = 0; i < argc; ++i) foo();
18 #pragma omp target
19 #pragma omp teams distribute parallel for simd num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
20   for (i = 0; i < argc; ++i) foo();
21 #pragma omp target
22 #pragma omp teams distribute parallel for simd num_threads () // expected-error {{expected expression}}
23   for (i = 0; i < argc; ++i) foo();
24 #pragma omp target
25 #pragma omp teams distribute parallel for simd num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
26   for (i = 0; i < argc; ++i) foo();
27 #pragma omp target
28 #pragma omp teams distribute parallel for simd num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
29   for (i = 0; i < argc; ++i) foo();
30 #pragma omp target
31 #pragma omp teams distribute parallel for simd num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
32   for (i = 0; i < argc; ++i) foo();
33 #pragma omp target
34 #pragma omp teams distribute parallel for simd num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
35   for (i = 0; i < argc; ++i) foo();
36 #pragma omp target
37 #pragma omp teams distribute parallel for simd num_threads (S) // expected-error {{'S' does not refer to a value}}
38   for (i = 0; i < argc; ++i) foo();
39 #pragma omp target
40 #pragma omp teams distribute parallel for simd num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
41   for (i = 0; i < argc; ++i) foo();
42 #pragma omp target
43 #pragma omp teams distribute parallel for simd num_threads (argc)
44   for (i = 0; i < argc; ++i) foo();
45 #pragma omp target
46 #pragma omp teams distribute parallel for simd num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
47   for (i = 0; i < argc; ++i) foo();
48
49   return argc;
50 }
51
52 int main(int argc, char **argv) {
53   int i;
54 #pragma omp target
55 #pragma omp teams distribute parallel for simd num_threads // expected-error {{expected '(' after 'num_threads'}}
56   for (i = 0; i < argc; ++i) foo();
57 #pragma omp target
58 #pragma omp teams distribute parallel for simd num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
59   for (i = 0; i < argc; ++i) foo();
60 #pragma omp target
61 #pragma omp teams distribute parallel for simd num_threads () // expected-error {{expected expression}}
62   for (i = 0; i < argc; ++i) foo();
63 #pragma omp target
64 #pragma omp teams distribute parallel for simd num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
65   for (i = 0; i < argc; ++i) foo();
66 #pragma omp target
67 #pragma omp teams distribute parallel for simd num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
68   for (i = 0; i < argc; ++i) foo();
69 #pragma omp target
70 #pragma omp teams distribute parallel for simd num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
71   for (i = 0; i < argc; ++i) foo();
72 #pragma omp target
73 #pragma omp teams distribute parallel for simd num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
74   for (i = 0; i < argc; ++i) foo();
75 #pragma omp target
76 #pragma omp teams distribute parallel for simd num_threads (S1) // expected-error {{'S1' does not refer to a value}}
77   for (i = 0; i < argc; ++i) foo();
78 #pragma omp target
79 #pragma omp teams distribute parallel for simd num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
80   for (i = 0; i < argc; ++i) foo();
81 #pragma omp target
82 #pragma omp teams distribute parallel for simd num_threads (num_threads(tmain<int, char, -1>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1>' requested here}}
83   for (i = 0; i < argc; ++i) foo();
84
85   return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
86 }