+2019-10-14 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.c (c_parser_omp_all_clauses): Change bool NESTED_P argument
+ into int NESTED, if it is 2, diagnose missing commas in between
+ clauses.
+ (c_parser_omp_context_selector): Pass 2 as last argument to
+ c_parser_omp_all_clauses.
+
2019-10-12 Jakub Jelinek <jakub@redhat.com>
* c-parser.c (c_parser_omp_context_selector): Improve error recovery.
/* Parse all OpenMP clauses. The set clauses allowed by the directive
is a bitmask in MASK. Return the list of clauses found.
FINISH_P set if c_finish_omp_clauses should be called.
- NESTED_P set if clauses should be terminated by closing paren instead
- of end of pragma. */
+ NESTED non-zero if clauses should be terminated by closing paren instead
+ of end of pragma. If it is 2, additionally commas are required in between
+ the clauses. */
static tree
c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask,
const char *where, bool finish_p = true,
- bool nested_p = false)
+ int nested = 0)
{
tree clauses = NULL;
bool first = true;
const char *c_name;
tree prev = clauses;
- if (nested_p && c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
+ if (nested && c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
break;
- if (!first && c_parser_next_token_is (parser, CPP_COMMA))
- c_parser_consume_token (parser);
+ if (!first)
+ {
+ if (c_parser_next_token_is (parser, CPP_COMMA))
+ c_parser_consume_token (parser);
+ else if (nested == 2)
+ error_at (c_parser_peek_token (parser)->location,
+ "clauses in %<simd%> trait should be separated "
+ "by %<,%>");
+ }
here = c_parser_peek_token (parser)->location;
c_kind = c_parser_omp_clause_name (parser);
}
saw_error:
- if (!nested_p)
+ if (!nested)
c_parser_skip_to_pragma_eol (parser);
if (finish_p)
tree c;
c = c_parser_omp_all_clauses (parser,
OMP_DECLARE_SIMD_CLAUSE_MASK,
- "simd", true, true);
+ "simd", true, 2);
c = c_omp_declare_simd_clauses_to_numbers (parms
== error_mark_node
? NULL_TREE : parms,
+2019-10-14 Jakub Jelinek <jakub@redhat.com>
+
+ * parser.c (cp_parser_omp_all_clauses): Change bool NESTED_P argument
+ into int NESTED, if it is 2, diagnose missing commas in between
+ clauses.
+ (cp_parser_omp_context_selector): Pass 2 as last argument to
+ cp_parser_omp_all_clauses.
+
2019-10-12 Jakub Jelinek <jakub@redhat.com>
* parser.c (cp_parser_omp_context_selector): Improve error recovery.
/* Parse all OpenMP clauses. The set clauses allowed by the directive
is a bitmask in MASK. Return the list of clauses found.
FINISH_P set if finish_omp_clauses should be called.
- NESTED_P set if clauses should be terminated by closing paren instead
- of end of pragma. */
+ NESTED non-zero if clauses should be terminated by closing paren instead
+ of end of pragma. If it is 2, additionally commas are required in between
+ the clauses. */
static tree
cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask,
const char *where, cp_token *pragma_tok,
- bool finish_p = true, bool nested_p = false)
+ bool finish_p = true, int nested = 0)
{
tree clauses = NULL;
bool first = true;
const char *c_name;
tree prev = clauses;
- if (nested_p && cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_PAREN))
+ if (nested && cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_PAREN))
break;
- if (!first && cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
- cp_lexer_consume_token (parser->lexer);
+ if (!first)
+ {
+ if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
+ cp_lexer_consume_token (parser->lexer);
+ else if (nested == 2)
+ error_at (cp_lexer_peek_token (parser->lexer)->location,
+ "clauses in %<simd%> trait should be separated "
+ "by %<,%>");
+ }
token = cp_lexer_peek_token (parser->lexer);
c_kind = cp_parser_omp_clause_name (parser);
}
}
saw_error:
- if (!nested_p)
+ if (!nested)
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
if (finish_p)
{
properties
= cp_parser_omp_all_clauses (parser,
OMP_DECLARE_SIMD_CLAUSE_MASK,
- "simd", NULL, true, true);
+ "simd", NULL, true, 2);
break;
default:
gcc_unreachable ();
+2019-10-14 Jakub Jelinek <jakub@redhat.com>
+
+ * c-c++-common/gomp/declare-variant-7.c: Add tests for clauses not
+ separated by commas in simd selector trait properties.
+
2019-10-14 Aldy Hernandez <aldyh@redhat.com>
* gcc.dg/tree-ssa/evrp4.c: Adjust for unsigned non-zero being
int f11 (float x, float y, float *z);
#pragma omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})
int f12 (int x, int y);
-#pragma omp declare variant (f3) match (construct={simd(inbranch,simdlen(5-1),linear(q:4-3))})
+#pragma omp declare variant (f3) match (construct={simd(inbranch, simdlen (5-1), linear (q:4-3))})
int f13 (int x, int q);
#pragma omp declare variant (f3) match (construct={simd(inbranch,simdlen(4),linear(q:2))}) /* { dg-error "'f3' used as a variant with incompatible 'constructor' selector sets" "" { target c } } */
int f14 (int x, int q);
+#pragma omp declare variant (f3) match (construct={simd(inbranch simdlen (4) linear (q:1))}) /* { dg-error "clauses in 'simd' trait should be separated by ','" } */
+int f15 (int x, int q);
+#pragma omp declare variant (f3) match (construct={simd(inbranch, simdlen (5-1) linear (q:4-3))}) /* { dg-error "clauses in 'simd' trait should be separated by ','" } */
+int f16 (int x, int q);