I now have seen several times that in an explanation of syntax the phrase structured-block was used. For example:
#pragma omp single
structured-block
(This is from OpenMP, but that doesn't matter.)
Would the following two lines also count as a structured-block?
do_something1;
do_something2;
or only the first statement alone?
So, to put it shortly: What do they mean when saying structured-block?
Based on the documentation here:
A “structured block” is a single statement or a compound statement with a single entry at the top and a single exit at the bottom
Looking up the definition of a compound statement here:
A compound statement, or block, is a brace-enclosed sequence of statements and declarations.
Given this definition, do_something1;
would be the only one part of the structured block as a new "single" statement begins after that. On the other hand if you did
#pragma omp <directive>
{
do_something1;
do_something2;
}
it would have both in the structured block as its a "compound" statement.
Finally, note the definition stating single entry at the top and a single exit at the bottom
. This simply means that we should not have an intermediate exit/control-flow breaking point like a goto
statement, return
or throw error
in between.