On Fri, 23 Dec 2022 04:13:03 -0800
Julian Brown <jul...@codesourcery.com> wrote:

> This patch adds support for "declare mapper" directives (and the
> "mapper" modifier on "map" clauses) for C.  As for C++, arrays of
> custom-mapped objects are not supported yet.

Here's a small follow-up for this one.

Re-tested (with previous patches) with offloading to nvptx.

OK?

Julian
commit be53bd5db61c2e4a093a00c371ba8395737d9be9
Author: Julian Brown <jul...@codesourcery.com>
Date:   Fri Jan 6 12:05:56 2023 +0000

    OpenMP: Use c_parser_check_balanced_raw_token_sequence parsing mapper modifier
    
    This is a small cumulative patch to simplify mapper modifier parsing in
    c_parser_omp_clause_map, making an approximately-equivalent change to the
    one Jakub suggested in the review for the C++ "declare mapper" patch here:
    
      https://gcc.gnu.org/pipermail/gcc-patches/2022-May/595523.html
    
    The C version isn't quite so terse, but is still a slight improvement
    over the previous code, I think.
    
    2023-01-09  Julian Brown  <jul...@codesourcery.com>
    
    gcc/c/
            * c-parser.cc (c_parser_omp_clause_map): Use
            c_parser_check_balanced_raw_token_sequence to traverse mapper modifier
            syntax.

diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 5dca50850b38..a1b377edd886 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -17242,20 +17242,18 @@ c_parser_omp_clause_map (c_parser *parser, tree list, enum gomp_map_kind kind)
 
       if (c_parser_peek_nth_token_raw (parser, pos + 1)->type == CPP_COMMA)
 	pos++;
-      else if ((c_parser_peek_nth_token_raw (parser, pos + 1)->type
-		== CPP_OPEN_PAREN)
-	       && ((c_parser_peek_nth_token_raw (parser, pos + 2)->type
-		    == CPP_NAME)
-		   || ((c_parser_peek_nth_token_raw (parser, pos + 2)->type
-			== CPP_KEYWORD)
-		       && (c_parser_peek_nth_token_raw (parser,
-							pos + 2)->keyword
-			   == RID_DEFAULT)))
-	       && (c_parser_peek_nth_token_raw (parser, pos + 3)->type
-		   == CPP_CLOSE_PAREN)
-	       && (c_parser_peek_nth_token_raw (parser, pos + 4)->type
-		   == CPP_COMMA))
-	pos += 4;
+      else if (c_parser_peek_nth_token_raw (parser, pos + 1)->type
+	       == CPP_OPEN_PAREN)
+	{
+	  unsigned int npos = pos + 2;
+	  if (c_parser_check_balanced_raw_token_sequence (parser, &npos)
+	      && (c_parser_peek_nth_token_raw (parser, npos)->type
+		  == CPP_CLOSE_PAREN)
+	      && (c_parser_peek_nth_token_raw (parser, npos + 1)->type
+		  == CPP_COMMA))
+	    pos = npos + 1;
+	}
+
       pos++;
     }
 

Reply via email to