On Mon, Jun 25, 2012 at 11:04:42AM -0400, Jason Merrill wrote: > Right, I just wasn't sure what the point of the test was. Is it > that if we're declaring the iteration variable in the > for-init-statement, we don't need to worry about making it OMP > private?
It should be made private always. Even for int foo (void) { int j; j = 6; #pragma omp for private(j) for (int i = 0; i < 6; i++) j = i; return j; } we declare it before #pragma omp for and make it private(i). > >Looking at the code now, I wonder whether begin_omp_structured_block > >shouldn't be moved later, not earlier, because the decl ctors should happen > >before the body of the worksharing region. > > Should they? It seems that each of the private copies of the decl > gets initialized separately, which I would expect to be part of the > worksharing region. Well, this is a worksharing region, so is already entered by all the threads, thus the initialization is performed by all threads anyway, the thing is just where the remapping of the var into the private var happens (and that should be performed by the gimplifier). Anyway, please go ahead with your patch. Jakub