The OpenMP allocate directive is not a construct, and thus is not supposed
to be handled by cp_parser_omp_construct, as far as I can tell it never was.
With this change PRAGMA_OMP_ALLOCATE will correctly trap if handled here,
as such this patch should have no functional impact, merely clarifying
intent and preventing future incorrect usage.

This also adds a few clarifying comments, based on my interpretation of the
code. The significance of the return value of cp_parser_pragma is still not
totally clear to me so no general comments are included for it.

gcc/cp/ChangeLog:

        * parser.cc (cp_parser_omp_construct)
        <case PRAGMA_OMP_ALLOCATE>: Remove.
        (cp_parser_pragma): Add comments.

Signed-off-by: Waffl3x <[email protected]>
---
 gcc/cp/parser.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index dc67cfd9f7c..ed24621452a 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -56537,9 +56537,6 @@ cp_parser_omp_construct (cp_parser *parser, cp_token 
*pragma_tok, bool *if_p)
     case PRAGMA_OACC_WAIT:
       stmt = cp_parser_oacc_wait (parser, pragma_tok);
       break;
-    case PRAGMA_OMP_ALLOCATE:
-      cp_parser_omp_allocate (parser, pragma_tok);
-      return;
     case PRAGMA_OMP_ATOMIC:
       cp_parser_omp_atomic (parser, pragma_tok, false);
       return;
@@ -57249,7 +57246,9 @@ cp_parser_pragma (cp_parser *parser, enum 
pragma_context context, bool *if_p)
       cp_parser_omp_construct (parser, pragma_tok, if_p);
       return true;
     case PRAGMA_OMP_ALLOCATE:
+      /* The allocate directive is not a construct.  */
       cp_parser_omp_allocate (parser, pragma_tok);
+      /* EOL is handled in cp_parser_omp_allocate, don't break.  */
       return false;
     case PRAGMA_OACC_ATOMIC:
     case PRAGMA_OACC_CACHE:
-- 
2.54.0

Reply via email to