The omp barrier directive identifies a synchronization point at which threads in a parallel region will not execute beyond the omp barrier until all other threads in the team complete all explicit tasks in the region.
if (x!=0) {
#pragma omp barrier /* valid usage */
}
if (x!=0)
#pragma omp barrier /* invalid usage */