This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: OpenMP directive turns a statement into a real code block [with proper example]


On Sat, Jun 20, 2009 at 08:30:30AM -0700, Tim Prince wrote:
> Peter Cech wrote:
> 
> >   # pragma omp parallel for
> >     for (int i = 0; i < 10; ++i) {
> >   #   pragma omp critical
> >       Class instance = create_and_register_new_instance();
> > 
> >       instance.do_something();
> >     }
> But still, turning on OpenMP here creates a new inner block scope, as you
> suggested the first time, so the compiler is right to throw the error.

But why? I was trying to find some relevant info, but the only thing I
found so far is this paragraph taken from OpenMP specification:

  An expression statement, iteration statement, selection statement,
  or try block is considered to be a structured block if the
  corresponding compound statement obtained by enclosing it in {
  and } would be a structured block.

The wording does not seem to require the expression statement to be
actually turned into a block for compilation. Did I miss this
requirement somewhere? Or is it one of the things left open?

Thanks,
Peter


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]