openmp: Diagnose another case of mixing parameter and attribute syntax
authorJakub Jelinek <jakub@redhat.com>
Thu, 12 Aug 2021 07:18:23 +0000 (09:18 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 12 Aug 2021 07:34:16 +0000 (09:34 +0200)
commitef07b918a7ad4f64e0e1e3db21d861f2e79de92a
tree1215789c5a20c7c4ed3826a1d8801190ea429d94
parent9b7ab853bf33106fd0539e36d6ce7730269026e1
openmp: Diagnose another case of mixing parameter and attribute syntax

This patch diagnoses cases like:
  #pragma omp parallel
  [[omp::directive (declare simd)]] int foo ();
or
  #pragma omp taskgroup
  int bar [[omp::directive (declare simd)]] (int);
where the pragma is on the same declaration statement as the declare simd
attribute.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

* parser.c (cp_parser_lambda_body): Add temp overrides
for parser->{omp_declare_simd,oacc_routine,omp_attrs_forbidden_p}.
(cp_parser_statement): Restore parser->omp_attrs_forbidden_p for
cp_parser_declaration_statement.
(cp_parser_default_argument): Add temp override for
parser->omp_attrs_forbidden_p.
(cp_parser_late_parsing_omp_declare_simd): Diagnose declare simd
or declare variant in attribute syntax on a declaration immediately
following an OpenMP construct in pragma syntax.

* g++.dg/gomp/attrs-11.C: Add new tests.
gcc/cp/parser.c
gcc/testsuite/g++.dg/gomp/attrs-11.C