172 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 -fopenmp -fopenmp-version=60 -fsyntax-only -Wuninitialized -verify %s2 3void func() {4 5 // expected-error@+1 {{expected '('}}6 #pragma omp stripe sizes7 ;8 9 // expected-error@+2 {{expected expression}}10 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}11 #pragma omp stripe sizes(12 ;13 14 // expected-error@+1 {{expected expression}}15 #pragma omp stripe sizes()16 ;17 18 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}19 #pragma omp stripe sizes(520 for (int i = 0; i < 7; ++i);21 22 // expected-error@+2 {{expected expression}}23 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}24 #pragma omp stripe sizes(5,25 ;26 27 // expected-error@+1 {{expected expression}}28 #pragma omp stripe sizes(5,)29 ;30 31 // expected-error@+2 {{expected expression}}32 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}33 #pragma omp stripe sizes(5+34 ;35 36 // expected-error@+1 {{expected expression}}37 #pragma omp stripe sizes(5+)38 ;39 40 // expected-error@+1 {{expected expression}}41 #pragma omp stripe sizes(for)42 ;43 44 // expected-error@+1 {{argument to 'sizes' clause must be a strictly positive integer value}}45 #pragma omp stripe sizes(0)46 for (int i = 0; i < 7; ++i)47 ;48 49 // expected-warning@+2 {{extra tokens at the end of '#pragma omp stripe' are ignored}}50 // expected-error@+1 {{directive '#pragma omp stripe' requires the 'sizes' clause}}51 #pragma omp stripe foo52 ;53 54 // expected-error@+1 {{directive '#pragma omp stripe' cannot contain more than one 'sizes' clause}}55 #pragma omp stripe sizes(5) sizes(5)56 for (int i = 0; i < 7; ++i)57 ;58 59 // expected-error@+1 {{unexpected OpenMP clause 'collapse' in directive '#pragma omp stripe'}}60 #pragma omp stripe sizes(5) collapse(2)61 for (int i = 0; i < 7; ++i)62 ;63 64 {65 // expected-error@+2 {{expected statement}}66 #pragma omp stripe sizes(5)67 }68 69 // expected-error@+2 {{statement after '#pragma omp stripe' must be a for loop}}70 #pragma omp stripe sizes(5)71 int b = 0;72 73 // expected-error@+3 {{statement after '#pragma omp stripe' must be a for loop}}74 #pragma omp stripe sizes(5,5)75 for (int i = 0; i < 7; ++i)76 ;77 78 // expected-error@+2 {{statement after '#pragma omp stripe' must be a for loop}}79 #pragma omp stripe sizes(5,5)80 for (int i = 0; i < 7; ++i) {81 int k = 3;82 for (int j = 0; j < 7; ++j)83 ;84 }85 86 // expected-error@+3 {{expected loop invariant expression}}87 #pragma omp stripe sizes(5,5)88 for (int i = 0; i < 7; ++i)89 for (int j = i; j < 7; ++j)90 ;91 92 // expected-error@+3 {{expected loop invariant expression}}93 #pragma omp stripe sizes(5,5)94 for (int i = 0; i < 7; ++i)95 for (int j = 0; j < i; ++j)96 ;97 98 // expected-error@+3 {{expected loop invariant expression}}99 #pragma omp stripe sizes(5,5)100 for (int i = 0; i < 7; ++i)101 for (int j = 0; j < i; ++j)102 ;103 104 // expected-error@+5 {{expected 3 for loops after '#pragma omp for', but found only 2}}105 // expected-note@+1 {{as specified in 'collapse' clause}}106 #pragma omp for collapse(3)107 #pragma omp stripe sizes(5)108 for (int i = 0; i < 7; ++i)109 ;110 111 // expected-error@+2 {{statement after '#pragma omp stripe' must be a for loop}}112 #pragma omp stripe sizes(5)113 #pragma omp for114 for (int i = 0; i < 7; ++i)115 ;116 117 // expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}118 #pragma omp stripe sizes(5)119 for (int i = 0; i/3<7; ++i)120 ;121 122 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'struct S'}}123 struct S{} s;124 #pragma omp stripe sizes(s)125 for (int i = 0; i < 7; ++i)126 ;127}128 129 130template <typename T>131static void templated_func() {132 // In a template context, but expression itself not instantiation-dependent133 134 // expected-error@+1 {{argument to 'sizes' clause must be a strictly positive integer value}}135 #pragma omp stripe sizes(0)136 for (int i = 0; i < 7; ++i)137 ;138}139 140template <int S>141static void templated_func_value_dependent() {142 // expected-error@+1 {{argument to 'sizes' clause must be a strictly positive integer value}}143 #pragma omp stripe sizes(S)144 for (int i = 0; i < 7; ++i)145 ;146}147 148template <typename T>149static void templated_func_type_dependent() {150 constexpr T s = 0;151 // expected-error@+1 {{argument to 'sizes' clause must be a strictly positive integer value}}152 #pragma omp stripe sizes(s)153 for (int i = 0; i < 7; ++i)154 ;155}156 157void template_inst() {158 templated_func<int>();159 // expected-note@+1 {{in instantiation of function template specialization 'templated_func_value_dependent<0>' requested here}}160 templated_func_value_dependent<0>();161 // expected-note@+1 {{in instantiation of function template specialization 'templated_func_type_dependent<int>' requested here}}162 templated_func_type_dependent<int>();163}164 165namespace GH139433 {166void f() {167#pragma omp stripe sizes(a) // expected-error {{use of undeclared identifier 'a'}}168 for (int i = 0; i < 10; i++)169 ;170}171} // namespace GH139433172