From: Cesar Philippidis Date: Wed, 4 Nov 2015 22:09:53 +0000 (-0800) Subject: (cp_parser_oacc_single_int_clause): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3ceed675633b522b655ce4bea683f98e527aafaf;p=gcc.git (cp_parser_oacc_single_int_clause): New function. 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6243afac967..99ba1aee83b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2015-11-04 Cesar Philippidis + + * (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 * call.c (validate_conversion_obstack): Define unconditionally. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 12452e689ff..4f6cd2d9beb 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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);