blob: a18bc5d5edcb123ed14501d8fdcef1966b786d33 [file] [log] [blame]
Alexey Bataeva9148882019-07-08 15:45:24 +00001// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +00002
Alexey Bataeva9148882019-07-08 15:45:24 +00003// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00004
Alexey Bataevc2c21ef2019-07-11 14:54:17 +00005void xxx(int argc) {
6 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7#pragma omp target depend(in : argc)
8 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
9}
10
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000011void foo() {
12}
13
14bool foobool(int argc) {
15 return argc;
16}
17
18struct S1; // expected-note {{declared here}}
19
20class vector {
21 public:
22 int operator[](int index) { return 0; }
23};
24
25int main(int argc, char **argv, char *env[]) {
26 vector vec;
27 typedef float V __attribute__((vector_size(16)));
28 V a;
29 auto arr = x; // expected-error {{use of undeclared identifier 'x'}}
30
31 #pragma omp target depend // expected-error {{expected '(' after 'depend'}}
32 foo();
Sergi Mateo Bellido31df1ad2019-02-04 07:33:19 +000033 #pragma omp target depend ( // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000034 foo();
Sergi Mateo Bellido31df1ad2019-02-04 07:33:19 +000035 #pragma omp target depend () // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000036 foo();
Sergi Mateo Bellido31df1ad2019-02-04 07:33:19 +000037 #pragma omp target depend (argc // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000038 foo();
Sergi Mateo Bellido31df1ad2019-02-04 07:33:19 +000039 #pragma omp target depend (source : argc) // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}}
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000040 foo();
41 #pragma omp target depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}}
42 foo();
43 #pragma omp target depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
44 foo();
45 #pragma omp target depend (out: ) // expected-error {{expected expression}}
46 foo();
Alexey Bataev463a9fe2017-07-27 19:15:30 +000047 #pragma omp target depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected addressable lvalue expression, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000048 foo();
49 #pragma omp target depend (out :S1) // expected-error {{'S1' does not refer to a value}}
50 foo();
Alexey Bataev463a9fe2017-07-27 19:15:30 +000051 #pragma omp target depend(in : argv[1][1] = '2')
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000052 foo();
Alexey Bataev463a9fe2017-07-27 19:15:30 +000053 #pragma omp target depend (in : vec[1]) // expected-error {{expected addressable lvalue expression, array element or array section}}
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000054 foo();
55 #pragma omp target depend (in : argv[0])
56 foo();
57 #pragma omp target depend (in : ) // expected-error {{expected expression}}
58 foo();
Alexey Bataev463a9fe2017-07-27 19:15:30 +000059 #pragma omp target depend (in : main)
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000060 foo();
Alexey Bataev463a9fe2017-07-27 19:15:30 +000061 #pragma omp target depend(in : a[0]) // expected-error{{expected addressable lvalue expression, array element or array section}}
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000062 foo();
63 #pragma omp target depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}}
64 foo();
65 #pragma omp target depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
66 foo();
67 #pragma omp target depend (in : argv[: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
68 foo();
69 #pragma omp target depend (in : argv[:] // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} expected-error {{expected ')'}} expected-note {{to match this '('}}
70 foo();
71 #pragma omp target depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
72 foo();
73 #pragma omp target depend (in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}}
74 foo();
75 #pragma omp target depend (in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
76 foo();
Kelvin Liad9ecba2016-07-20 20:45:29 +000077 #pragma omp target depend (in : argv[-1:0])
Arpith Chacko Jacobcef5c952016-01-22 00:49:21 +000078 foo();
79 #pragma omp target depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
80 foo();
81 #pragma omp target depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
82 foo();
83 #pragma omp target depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
84 foo();
85 #pragma omp target depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
86 foo();
87 #pragma omp target depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
88 foo();
89 #pragma omp target depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
90 foo();
91 #pragma omp target depend(in : argv[ : argc][1 : argc - 1])
92 foo();
93 #pragma omp target depend(in : arr[0])
94 foo();
95
96 return 0;
97}