A.23 (p216, l17-18) says "The following example is non-conforming, because the flush, barrier, and taskwait directives cannot be the immediate substatement of an if statement." but would the following program be conforming?
- Code: Select all
void foo()
{
int a = 1;
#pragma omp parallel
{
if (a != 0)
#pragma omp flush(a)
{
}
if (a != 0)
#pragma omp barrier
{
}
if (a != 0)
#pragma omp taskwait
{
}
}
}
void bar()
{
int a = 1;
#pragma omp parallel
{
if (a != 0)
#pragma omp flush(a)
;
if (a != 0)
#pragma omp barrier
;
if (a != 0)
#pragma omp taskwait
;
}
}
The program also has flush, barrier, and taskwait directives as "immediate substatements" (although this term is not defined anywhere).
In my opinion this program is valid, because all these directives can be deleted without getting incorrect syntax. It conforms to 2.8.3 (p64, l6-9), 2.8.6 (p69, l12-15) and 2.8.4 (p65, l13-16) "The directive ... may only be placed in the program at a position where ignoring or deleting the directive would result in a program with correct syntax".
Also, flush, barrier, and taskwait directives have no sense if placed at file-scope level. But according to previously noted Draft sections it is allowed.
