(cp_parser_oacc_single_int_clause): New function.
authorCesar Philippidis <cesar@codesourcery.com>
Wed, 4 Nov 2015 22:09:53 +0000 (14:09 -0800)
committerCesar Philippidis <cesar@gcc.gnu.org>
Wed, 4 Nov 2015 22:09:53 +0000 (14:09 -0800)
gcc/cp/
* (cp_parser_oacc_single_int_clause): New function.
(cp_parser_oacc_clause_vector_length): Delete.
(cp_parser_omp_clause_num_gangs): Delete.
(cp_parser_omp_clause_num_workers): Delete.
(cp_parser_oacc_all_clauses): Use cp_parser_oacc_single_int_clause
for num_gangs, num_workers and vector_length.

From-SVN: r229786

gcc/cp/ChangeLog
gcc/cp/parser.c

index 6243afac9671a8b282eba82b4e9dd9fac78f325c..99ba1aee83b90e6c7b6ee48071d103290fb2deb7 100644 (file)
@@ -1,3 +1,12 @@
+2015-11-04  Cesar Philippidis  <cesar@codesourcery.com>
+
+       * (cp_parser_oacc_single_int_clause): New function.
+       (cp_parser_oacc_clause_vector_length): Delete.
+       (cp_parser_omp_clause_num_gangs): Delete.
+       (cp_parser_omp_clause_num_workers): Delete.
+       (cp_parser_oacc_all_clauses): Use cp_parser_oacc_single_int_clause
+       for num_gangs, num_workers and vector_length.
+
 2015-11-04  Mikhail Maltsev  <maltsevm@gmail.com>
 
        * call.c (validate_conversion_obstack): Define unconditionally.
index 12452e689ff58f9eb0757f8ab8854d437ed92656..4f6cd2d9bebfb962215ce7a33fbe0c41b64ff203 100644 (file)
@@ -29590,6 +29590,39 @@ cp_parser_oacc_simple_clause (cp_parser * /* parser  */,
   return c;
 }
 
+ /* OpenACC:
+   num_gangs ( expression )
+   num_workers ( expression )
+   vector_length ( expression )  */
+
+static tree
+cp_parser_oacc_single_int_clause (cp_parser *parser, omp_clause_code code,
+                                 const char *str, tree list)
+{
+  location_t loc = cp_lexer_peek_token (parser->lexer)->location;
+
+  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
+    return list;
+
+  tree t = cp_parser_assignment_expression (parser, NULL, false, false);
+
+  if (t == error_mark_node
+      || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
+    {
+      cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
+                                            /*or_comma=*/false,
+                                            /*consume_paren=*/true);
+      return list;
+    }
+
+  check_no_duplicate_clause (list, code, str, loc);
+
+  tree c = build_omp_clause (loc, code);
+  OMP_CLAUSE_OPERAND (c, 0) = t;
+  OMP_CLAUSE_CHAIN (c) = list;
+  return c;
+}
+
 /* OpenACC:
 
     gang [( gang-arg-list )]
@@ -29713,45 +29746,6 @@ cp_parser_oacc_shape_clause (cp_parser *parser, omp_clause_code kind,
   return list;
 }
 
-/* OpenACC:
-   vector_length ( expression ) */
-
-static tree
-cp_parser_oacc_clause_vector_length (cp_parser *parser, tree list)
-{
-  tree t, c;
-  location_t location = cp_lexer_peek_token (parser->lexer)->location;
-  bool error = false;
-
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
-    return list;
-
-  t = cp_parser_condition (parser);
-  if (t == error_mark_node || !INTEGRAL_TYPE_P (TREE_TYPE (t)))
-    {
-      error_at (location, "expected positive integer expression");
-      error = true;
-    }
-
-  if (error || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
-    {
-      cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
-                                          /*or_comma=*/false,
-                                          /*consume_paren=*/true);
-      return list;
-    }
-
-  check_no_duplicate_clause (list, OMP_CLAUSE_VECTOR_LENGTH, "vector_length",
-                            location);
-
-  c = build_omp_clause (location, OMP_CLAUSE_VECTOR_LENGTH);
-  OMP_CLAUSE_VECTOR_LENGTH_EXPR (c) = t;
-  OMP_CLAUSE_CHAIN (c) = list;
-  list = c;
-
-  return list;
-}
-
 /* OpenACC 2.0
    Parse wait clause or directive parameters.  */
 
@@ -30130,42 +30124,6 @@ cp_parser_omp_clause_nowait (cp_parser * /*parser*/,
   return c;
 }
 
-/* OpenACC:
-   num_gangs ( expression ) */
-
-static tree
-cp_parser_omp_clause_num_gangs (cp_parser *parser, tree list)
-{
-  tree t, c;
-  location_t location = cp_lexer_peek_token (parser->lexer)->location;
-
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
-    return list;
-
-  t = cp_parser_condition (parser);
-
-  if (t == error_mark_node
-      || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
-    cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
-                                          /*or_comma=*/false,
-                                          /*consume_paren=*/true);
-
-  if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
-    {
-      error_at (location, "expected positive integer expression");
-      return list;
-    }
-
-  check_no_duplicate_clause (list, OMP_CLAUSE_NUM_GANGS, "num_gangs", location);
-
-  c = build_omp_clause (location, OMP_CLAUSE_NUM_GANGS);
-  OMP_CLAUSE_NUM_GANGS_EXPR (c) = t;
-  OMP_CLAUSE_CHAIN (c) = list;
-  list = c;
-
-  return list;
-}
-
 /* OpenMP 2.5:
    num_threads ( expression ) */
 
@@ -30374,43 +30332,6 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
   return list;
 }
 
-/* OpenACC:
-   num_workers ( expression ) */
-
-static tree
-cp_parser_omp_clause_num_workers (cp_parser *parser, tree list)
-{
-  tree t, c;
-  location_t location = cp_lexer_peek_token (parser->lexer)->location;
-
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
-    return list;
-
-  t = cp_parser_condition (parser);
-
-  if (t == error_mark_node
-      || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
-    cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
-                                          /*or_comma=*/false,
-                                          /*consume_paren=*/true);
-
-  if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
-    {
-      error_at (location, "expected positive integer expression");
-      return list;
-    }
-
-  check_no_duplicate_clause (list, OMP_CLAUSE_NUM_WORKERS, "num_gangs",
-                                                               location);
-
-  c = build_omp_clause (location, OMP_CLAUSE_NUM_WORKERS);
-  OMP_CLAUSE_NUM_WORKERS_EXPR (c) = t;
-  OMP_CLAUSE_CHAIN (c) = list;
-  list = c;
-
-  return list;
-}
-
 /* OpenMP 2.5:
    ordered
 
@@ -31422,6 +31343,7 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask,
     {
       location_t here;
       pragma_omp_clause c_kind;
+      omp_clause_code code;
       const char *c_name;
       tree prev = clauses;
 
@@ -31488,12 +31410,16 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask,
          c_name = "if";
          break;
        case PRAGMA_OACC_CLAUSE_NUM_GANGS:
-         clauses = cp_parser_omp_clause_num_gangs (parser, clauses);
+         code = OMP_CLAUSE_NUM_GANGS;
          c_name = "num_gangs";
+         clauses = cp_parser_oacc_single_int_clause (parser, code, c_name,
+                                                     clauses);
          break;
        case PRAGMA_OACC_CLAUSE_NUM_WORKERS:
-         clauses = cp_parser_omp_clause_num_workers (parser, clauses);
          c_name = "num_workers";
+         code = OMP_CLAUSE_NUM_WORKERS;
+         clauses = cp_parser_oacc_single_int_clause (parser, code, c_name,
+                                                     clauses);
          break;
        case PRAGMA_OACC_CLAUSE_PRESENT:
          clauses = cp_parser_oacc_data_clause (parser, c_kind, clauses);
@@ -31534,8 +31460,10 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask,
                                                 c_name, clauses);
          break;
        case PRAGMA_OACC_CLAUSE_VECTOR_LENGTH:
-         clauses = cp_parser_oacc_clause_vector_length (parser, clauses);
          c_name = "vector_length";
+         code = OMP_CLAUSE_VECTOR_LENGTH;
+         clauses = cp_parser_oacc_single_int_clause (parser, code, c_name,
+                                                     clauses);
          break;
        case PRAGMA_OACC_CLAUSE_WAIT:
          clauses = cp_parser_oacc_clause_wait (parser, clauses);