Fix regressions introduced by block/statement skipping.
If user condition selector is constant, do not return it as a dynamic
selector.
2022-01-25 Kwok Cheung Yeung <kcy@codesourcery.com>
gcc/c/
* c-parser.c (c_parser_skip_to_end_of_block_or_statement): Track
bracket depth separately from nesting depth.
gcc/cp/
* parser.c (cp_parser_skip_to_end_of_statement): Revert.
(cp_parser_skip_to_end_of_block_or_statement): Track bracket depth
separately from nesting depth.
gcc/
* omp-general.c (omp_dynamic_cond): Do not return user condition if
constant.
+2022-01-25 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * omp-general.c (omp_dynamic_cond): Do not return user condition if
+ constant.
+
2022-01-25 Kwok Cheung Yeung <kcy@codesourcery.com>
* omp-general.c (omp_check_context_selector): Revert string length
+2022-01-25 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * c-parser.c (c_parser_skip_to_end_of_block_or_statement): Track
+ bracket depth separately from nesting depth.
+
2022-01-25 Kwok Cheung Yeung <kcy@codesourcery.com>
* c-parser.c (c_parser_skip_to_end_of_block_or_statement): Handle
c_parser_skip_to_end_of_block_or_statement (c_parser *parser)
{
unsigned nesting_depth = 0;
+ int bracket_depth = 0;
bool save_error = parser->error;
while (true)
case CPP_SEMICOLON:
/* If the next token is a ';', we have reached the
end of the statement. */
- if (!nesting_depth)
+ if (!nesting_depth && bracket_depth <= 0)
{
/* Consume the ';'. */
c_parser_consume_token (parser);
/* Track parentheses in case the statement is a standalone 'for'
statement - we want to skip over the semicolons separating the
operands. */
- nesting_depth++;
+ if (nesting_depth == 0)
+ ++bracket_depth;
break;
case CPP_CLOSE_PAREN:
- nesting_depth--;
+ if (nesting_depth == 0)
+ --bracket_depth;
break;
case CPP_PRAGMA:
+2022-01-25 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * parser.c (cp_parser_skip_to_end_of_statement): Revert.
+ (cp_parser_skip_to_end_of_block_or_statement): Track bracket depth
+ separately from nesting depth.
+
2022-01-25 Kwok Cheung Yeung <kcy@codesourcery.com>
* parser.c (cp_parser_skip_to_end_of_statement): Handle parentheses.
++nesting_depth;
break;
- case CPP_OPEN_PAREN:
- /* Track parentheses in case the statement is a standalone 'for'
- statement - we want to skip over the semicolons separating the
- operands. */
- ++nesting_depth;
- break;
-
- case CPP_CLOSE_PAREN:
- --nesting_depth;
- break;
-
case CPP_KEYWORD:
if (token->keyword != RID__EXPORT
&& token->keyword != RID__MODULE
cp_parser_skip_to_end_of_block_or_statement (cp_parser* parser)
{
int nesting_depth = 0;
+ int bracket_depth = 0;
/* Unwind generic function template scope if necessary. */
if (parser->fully_implicit_function_template_p)
case CPP_SEMICOLON:
/* Stop if this is an unnested ';'. */
- if (!nesting_depth)
+ if (!nesting_depth && bracket_depth <= 0)
nesting_depth = -1;
break;
/* Track parentheses in case the statement is a standalone 'for'
statement - we want to skip over the semicolons separating the
operands. */
- nesting_depth++;
+ if (nesting_depth == 0)
+ bracket_depth++;
break;
case CPP_CLOSE_PAREN:
- nesting_depth--;
+ if (nesting_depth == 0)
+ bracket_depth--;
break;
case CPP_KEYWORD:
}
/* Return a tree expression representing the dynamic part of the context
- * selector CTX. */
+ selector CTX. */
static tree
omp_dynamic_cond (tree ctx)
tree expr_list = TREE_VALUE (user);
gcc_assert (TREE_PURPOSE (expr_list) == NULL_TREE);
- return TREE_VALUE (expr_list);
+
+ /* The user condition is not dynamic if it is constant. */
+ if (!tree_fits_shwi_p (TREE_VALUE (expr_list)))
+ return TREE_VALUE (expr_list);
}
+
return NULL_TREE;
}