Skip to content
Snippets Groups Projects
Commit 89999f23 authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

openmp: Allow optional comma after directive-specifier in C/C++

Previously we've been allowing that comma only in C++ when in attribute
form (which was the reason why it has been allowed), but 5.1 allows that
even in pragma form in C/C++ (with clarifications in 5.2) and 5.2
also in Fortran (which this patch doesn't implement).

Note, for directives which take an argument (== unnamed clause),
comma is not allowed in between the directive name and the argument,
like the directive-1.c testcase shows.

2022-10-28  Jakub Jelinek  <jakub@redhat.com>

gcc/c/
	* c-parser.cc (c_parser_omp_all_clauses): Allow optional
	comma before the first clause.
	(c_parser_omp_allocate, c_parser_omp_atomic, c_parser_omp_depobj,
	c_parser_omp_flush, c_parser_omp_scan_loop_body,
	c_parser_omp_ordered, c_finish_omp_declare_variant,
	c_parser_omp_declare_target, c_parser_omp_declare_reduction,
	c_parser_omp_requires, c_parser_omp_error,
	c_parser_omp_assumption_clauses): Likewise.
gcc/cp/
	* parser.cc (cp_parser_omp_all_clauses): Allow optional comma
	before the first clause even in pragma syntax.
	(cp_parser_omp_allocate, cp_parser_omp_atomic, cp_parser_omp_depobj,
	cp_parser_omp_flush, cp_parser_omp_scan_loop_body,
	cp_parser_omp_ordered, cp_parser_omp_assumption_clauses,
	cp_finish_omp_declare_variant, cp_parser_omp_declare_target,
	cp_parser_omp_declare_reduction_exprs, cp_parser_omp_requires,
	cp_parser_omp_error): Likewise.
gcc/testsuite/
	* c-c++-common/gomp/directive-1.c: New test.
	* c-c++-common/gomp/clauses-6.c: New test.
	* c-c++-common/gomp/declare-variant-2.c (f75a): Declare.
	(f75): Use f75a as variant instead of f1 and don't expect error.
	* g++.dg/gomp/clause-4.C (foo): Don't expect error on comma
	before first clause.
	* gcc.dg/gomp/clause-2.c (foo): Likewise.
parent 826df6d0
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment