[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / simd_if_messages.cpp
blobd3f571f7e7e0ddc0c10051556c65359502ea5063
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 void foo() {
8 bool foobool(int argc) {
9 return argc;
12 void xxx(int argc) {
13 int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}
14 #pragma omp simd if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}
15 for (int i = 0; i < 10; ++i)
19 struct S1; // expected-note {{declared here}}
21 template <class T, class S> // expected-note {{declared here}}
22 int tmain(T argc, S **argv) {
23 T z;
24 int i;
25 #pragma omp simd if // expected-error {{expected '(' after 'if'}}
26 for (i = 0; i < argc; ++i) foo();
27 #pragma omp simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
28 for (i = 0; i < argc; ++i) foo();
29 #pragma omp simd if () // expected-error {{expected expression}}
30 for (i = 0; i < argc; ++i) foo();
31 #pragma omp simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
32 for (i = 0; i < argc; ++i) foo();
33 #pragma omp simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp simd' are ignored}}
34 for (i = 0; i < argc; ++i) foo();
35 #pragma omp simd if (argc > 0 ? argv[1] : argv[2])
36 for (i = 0; i < argc; ++i) foo();
37 #pragma omp simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp simd' cannot contain more than one 'if' clause}}
38 for (i = 0; i < argc; ++i) foo();
39 #pragma omp simd if (S) // expected-error {{'S' does not refer to a value}}
40 for (i = 0; i < argc; ++i) foo();
41 #pragma omp simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
42 for (i = 0; i < argc; ++i) foo();
43 #pragma omp simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
44 for (i = 0; i < argc; ++i) foo();
45 #pragma omp simd if(argc + z)
46 for (i = 0; i < argc; ++i) foo();
47 #pragma omp simd if(simd : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
48 for (i = 0; i < argc; ++i) foo();
49 #pragma omp simd if(simd : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
50 for (i = 0; i < argc; ++i) foo();
51 #pragma omp simd if(simd : argc)
52 for (i = 0; i < argc; ++i) foo();
53 #pragma omp simd if(target : argc) // expected-error {{directive name modifier 'target' is not allowed for '#pragma omp simd'}}
54 for (i = 0; i < argc; ++i) foo();
55 #pragma omp simd if(simd : argc) if (simd :argc) // expected-error {{directive '#pragma omp simd' cannot contain more than one 'if' clause with 'simd' name modifier}}
56 for (i = 0; i < argc; ++i) foo();
57 #pragma omp simd if(simd : argc) if (argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{no more 'if' clause is allowed}}
58 for (i = 0; i < argc; ++i) foo();
60 return 0;
63 int main(int argc, char **argv) {
64 int i, z;
65 #pragma omp simd if // expected-error {{expected '(' after 'if'}}
66 for (i = 0; i < argc; ++i) foo();
67 #pragma omp simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
68 for (i = 0; i < argc; ++i) foo();
69 #pragma omp simd if () // expected-error {{expected expression}}
70 for (i = 0; i < argc; ++i) foo();
71 #pragma omp simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
72 for (i = 0; i < argc; ++i) foo();
73 #pragma omp simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp simd' are ignored}}
74 for (i = 0; i < argc; ++i) foo();
75 #pragma omp simd if (argc > 0 ? argv[1] : argv[2])
76 for (i = 0; i < argc; ++i) foo();
77 #pragma omp simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp simd' cannot contain more than one 'if' clause}}
78 for (i = 0; i < argc; ++i) foo();
79 #pragma omp simd if (S1) // expected-error {{'S1' does not refer to a value}}
80 for (i = 0; i < argc; ++i) foo();
81 #pragma omp simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
82 for (i = 0; i < argc; ++i) foo();
83 #pragma omp simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
84 for (i = 0; i < argc; ++i) foo();
85 #pragma omp simd if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
86 for (i = 0; i < argc; ++i) foo();
87 #pragma omp simd if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
88 for (i = 0; i < argc; ++i) foo();
89 #pragma omp simd if(simd : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
90 for (i = 0; i < argc; ++i) foo();
91 #pragma omp simd if(simd : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
92 for (i = 0; i < argc; ++i) foo();
93 #pragma omp simd if(simd : argc + z) if (target:argc) // expected-error {{directive name modifier 'target' is not allowed for '#pragma omp simd'}}
94 for (i = 0; i < argc; ++i) foo();
95 #pragma omp simd if(simd : argc) if (simd :argc) // expected-error {{directive '#pragma omp simd' cannot contain more than one 'if' clause with 'simd' name modifier}}
96 for (i = 0; i < argc; ++i) foo();
97 #pragma omp simd if(simd : argc) if (argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{no more 'if' clause is allowed}}
98 for (i = 0; i < argc; ++i) foo();
100 return tmain(argc, argv);