openmp: Add support for omp attributes section and scan directives
authorJakub Jelinek <jakub@redhat.com>
Mon, 26 Jul 2021 07:13:47 +0000 (09:13 +0200)
committerJakub Jelinek <jakub@redhat.com>
Mon, 26 Jul 2021 07:13:47 +0000 (09:13 +0200)
commitacf9d1fd806fabf62dfe232439b11263c191e32d
tree8cab35a73a0994b4d209681a111d766eb1283f10
parent124bb55777c280a85d0c72ec13e293a32917a6b9
openmp: Add support for omp attributes section and scan directives

This patch adds support for expressing the section and scan directives
using the attribute syntax and additionally fixes some bugs in the attribute
syntax directive handling.
For now it requires that the scan and section directives appear as the only
attribute, not combined with other OpenMP or non-OpenMP attributes on the same
statement.

2021-07-26  Jakub Jelinek  <jakub@redhat.com>

* parser.h (struct cp_lexer): Add orphan_p member.
* parser.c (cp_parser_statement): Don't change in_omp_attribute_pragma
upon restart from CPP_PRAGMA handling.  Fix up condition when a lexer
should be destroyed and adjust saved_tokens if it records tokens from
the to be destroyed lexer.
(cp_parser_omp_section_scan): New function.
(cp_parser_omp_scan_loop_body): Use it.  If
parser->lexer->in_omp_attribute_pragma, allow optional comma
after scan.
(cp_parser_omp_sections_scope): Use cp_parser_omp_section_scan.

* g++.dg/gomp/attrs-1.C: Use attribute syntax even for section
and scan directives.
* g++.dg/gomp/attrs-2.C: Likewise.
* g++.dg/gomp/attrs-6.C: New test.
* g++.dg/gomp/attrs-7.C: New test.
* g++.dg/gomp/attrs-8.C: New test.
gcc/cp/parser.c
gcc/cp/parser.h
gcc/testsuite/g++.dg/gomp/attrs-1.C
gcc/testsuite/g++.dg/gomp/attrs-2.C
gcc/testsuite/g++.dg/gomp/attrs-6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/attrs-7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/attrs-8.C [new file with mode: 0644]