Debian Codegraph @

gcc/testsuite/g++.dg/gomp/for-22.C

raw
1 // { dg-do compile { target c++17 } }
2
3 namespace std {
4 template<typename T> struct tuple_size;
5 template<int, typename> struct tuple_element;
6 }
7
8 struct A {
9 int i;
10 template <int I> int& get() { return i; }
11 };
12
13 template<> struct std::tuple_size<A> { static const int value = 3; };
14 template<int I> struct std::tuple_element<I,A> { using type = int; };
15
16 struct B {
17 A *begin();
18 A *end();
19 };
20
21 void
22 f1 (B a)
23 {
24 #pragma omp for collapse (2)
25 for (auto [i, j, k] : a) // { dg-error "initializer expression refers to iteration variable 'i'" "" { target *-*-* } .+1 }
26 for (int l = i; l < j; l += k) // { dg-error "condition expression refers to iteration variable 'j'" }
27 ; // { dg-error "increment expression refers to iteration variable 'k'" "" { target *-*-* } .-1 }
28 }
29
30 template <int N>
31 void
32 f2 (B a)
33 {
34 #pragma omp for collapse (2)
35 for (auto [i, j, k] : a) // { dg-error "initializer expression refers to iteration variable 'i'" "" { target *-*-* } .-1 }
36 for (int l = i; l < j; l += k) // { dg-error "condition expression refers to iteration variable 'j'" }
37 ; // { dg-error "increment expression refers to iteration variable 'k'" "" { target *-*-* } .-3 }
38 }
39
40 template <typename T>
41 void
42 f3 (T a)
43 {
44 #pragma omp for collapse (2)
45 for (auto [i, j, k] : a) // { dg-error "initializer expression refers to iteration variable 'i'" "" { target *-*-* } .-1 }
46 for (int l = i; l < j; l += k) // { dg-error "condition expression refers to iteration variable 'j'" }
47 ; // { dg-error "increment expression refers to iteration variable 'k'" "" { target *-*-* } .-3 }
48 }
49
50 void
51 test ()
52 {
53 B b;
54 f1 (b);
55 f2 <0> (b);
56 f3 <B> (b);
57 }