blob: 3c35e7c54b68ecf6e516ce0ed3e9da183a70bed2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* { dg-do compile { target { c || c++11 } } } */
/* Check that a nested FOR loop with standard c/c++ attributes on it
(not the C++ attribute syntax for OpenMP directives)
gives an error. */
extern void do_something (void);
/* This one should be OK, an empty attribute list is ignored in both C
and C++. */
void imperfect1 (int x, int y)
{
#pragma omp for collapse (2)
for (int i = 0; i < x; i++)
{
[[]] for (int j = 0; j < y; j++)
do_something ();
}
}
void perfect1 (int x, int y)
{
#pragma omp for ordered (2)
for (int i = 0; i < x; i++)
{
[[]] for (int j = 0; j < y; j++)
do_something ();
}
}
/* Similar, but put the attributes on a block wrapping the nested loop
instead. This is not allowed by the grammar. */
void imperfect2 (int x, int y)
{
#pragma omp for collapse (2)
for (int i = 0; i < x; i++) /* { dg-error "not enough nested loops" } */
{
[[]]
{
for (int j = 0; j < y; j++) /* { dg-error "loop not permitted in intervening code" } */
do_something ();
}
}
}
void perfect2 (int x, int y)
{
#pragma omp for ordered (2)
for (int i = 0; i < x; i++) /* { dg-error "not enough nested loops" } */
/* { dg-error "inner loops must be perfectly nested" "" { target *-*-*} .-1 } */
{
[[]]
{
for (int j = 0; j < y; j++) /* { dg-error "loop not permitted in intervening code" } */
do_something ();
}
}
}
/* Make sure attributes are accepted in the innermost loop body, which has
no intervening code restrictions. */
void imperfect3 (int x, int y)
{
#pragma omp for collapse (2)
for (int i = 0; i < x; i++)
for (int j = 0; j < y; j++)
{
[[]] do_something ();
}
}
void perfect3 (int x, int y)
{
#pragma omp for ordered (2)
for (int i = 0; i < x; i++)
for (int j = 0; j < y; j++)
{
[[]] do_something ();
}
}
|