This is a followup to
ed49709acda OpenMP: C++ front-end support for dispatch + adjust_args.
The call to cp_parser_omp_dispatch only belongs in cp_parser_omp_construct. In
cp_parser_pragma, handle PRAGMA_OMP_DISPATCH by calling cp_parser_omp_construct.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_pragma): Replace call to cp_parser_omp_dispatch
with cp_parser_omp_construct and check context.
gcc/testsuite/ChangeLog:
* g++.dg/gomp/dispatch-8.C: New test.
break;
case PRAGMA_OMP_DISPATCH:
- cp_parser_omp_dispatch (parser, pragma_tok);
+ if (context != pragma_stmt && context != pragma_compound)
+ goto bad_stmt;
+ cp_parser_omp_construct (parser, pragma_tok, if_p);
return true;
case PRAGMA_IVDEP:
--- /dev/null
+// { dg-do compile }
+
+// Check that an appropriate diagnostic is emitted when a dispatch directive
+// appears in a pragma_member context.
+
+void k();
+struct t {
+ #pragma omp dispatch // { dg-error "expected declaration specifiers before end of line" }
+ k(); // { dg-error ".*" }
+};