]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/taskloop_simd_simdlen_messages.cpp
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / OpenMP / taskloop_simd_simdlen_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
4
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s
7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s
8
9 void foo() {
10 }
11
12 #if __cplusplus >= 201103L
13 // expected-note@+2 4 {{declared here}}
14 #endif
15 bool foobool(int argc) {
16   return argc;
17 }
18
19 struct S1; // expected-note {{declared here}}
20
21 template <class T, typename S, int N, int ST> // expected-note {{declared here}}
22 T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
23   #pragma omp taskloop simd simdlen // expected-error {{expected '(' after 'simdlen'}}
24   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
25   #pragma omp taskloop simd simdlen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
26   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
27   #pragma omp taskloop simd simdlen () // expected-error {{expected expression}}
28   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
29   // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
30   // expected-error@+2 2 {{expression is not an integral constant expression}}
31   // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
32   #pragma omp taskloop simd simdlen (argc 
33   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
34   // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
35   #pragma omp taskloop simd simdlen (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
36   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
37   #pragma omp taskloop simd simdlen (1)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
38   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
39   #pragma omp taskloop simd simdlen ((ST > 0) ? 1 + ST : 2)
40   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
41   // expected-error@+6 2 {{directive '#pragma omp taskloop simd' cannot contain more than one 'simdlen' clause}}
42   // expected-error@+5 2 {{argument to 'simdlen' clause must be a strictly positive integer value}}
43   // expected-error@+4 2 {{expression is not an integral constant expression}}
44 #if __cplusplus >= 201103L
45   // expected-note@+2 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
46 #endif
47   #pragma omp taskloop simd simdlen (foobool(argc)), simdlen (true), simdlen (-5)
48   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
49   #pragma omp taskloop simd simdlen (S) // expected-error {{'S' does not refer to a value}}
50   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
51 #if __cplusplus <= 199711L
52   // expected-error@+4 2 {{expression is not an integral constant expression}}
53 #else
54   // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
55 #endif
56   #pragma omp taskloop simd simdlen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
57   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
58   #pragma omp taskloop simd simdlen (4)
59   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
60   #pragma omp taskloop simd simdlen (N) // expected-error {{argument to 'simdlen' clause must be a strictly positive integer value}}
61   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
62   return argc;
63 }
64
65 int main(int argc, char **argv) {
66   #pragma omp taskloop simd simdlen // expected-error {{expected '(' after 'simdlen'}}
67   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
68   #pragma omp taskloop simd simdlen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
69   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
70   #pragma omp taskloop simd simdlen () // expected-error {{expected expression}}
71   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
72   #pragma omp taskloop simd simdlen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
73   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
74   #pragma omp taskloop simd simdlen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
75   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
76   // expected-error@+4 {{expression is not an integral constant expression}}
77 #if __cplusplus >= 201103L
78   // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
79 #endif
80   #pragma omp taskloop simd simdlen (foobool(1) > 0 ? 1 : 2)
81   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
82   // expected-error@+6 {{expression is not an integral constant expression}}
83 #if __cplusplus >= 201103L
84   // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
85 #endif
86   // expected-error@+2 2 {{directive '#pragma omp taskloop simd' cannot contain more than one 'simdlen' clause}}
87   // expected-error@+1 2 {{argument to 'simdlen' clause must be a strictly positive integer value}}
88   #pragma omp taskloop simd simdlen (foobool(argc)), simdlen (true), simdlen (-5) 
89   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
90   #pragma omp taskloop simd simdlen (S1) // expected-error {{'S1' does not refer to a value}}
91   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
92 #if __cplusplus <= 199711L
93   // expected-error@+4 {{expression is not an integral constant expression}}
94 #else
95   // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
96 #endif
97   #pragma omp taskloop simd simdlen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
98   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
99   // expected-error@+3 {{statement after '#pragma omp taskloop simd' must be a for loop}}
100   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
101   #pragma omp taskloop simd simdlen(simdlen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
102   foo();
103   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
104   return tmain<int, char, 12, 4>(argc, argv);
105 }
106