diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-11-14 09:14:16 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-11-14 09:14:16 +0100 |
commit | bedb7f045f3bc4ccf17f4b58f840c93acb821a3f (patch) | |
tree | fcccc411bdf6e64e0876f3eeeb76ff8b773b0243 /gcc/cp | |
parent | d0ec7c935f0c961b13f75c906b8621e35ce1ace5 (diff) | |
download | gcc-bedb7f045f3bc4ccf17f4b58f840c93acb821a3f.zip gcc-bedb7f045f3bc4ccf17f4b58f840c93acb821a3f.tar.gz gcc-bedb7f045f3bc4ccf17f4b58f840c93acb821a3f.tar.bz2 |
c-parser.c (c_parser_omp_context_selector): Don't require score argument to fit into shwi, just to be INTEGER_CST.
* c-parser.c (c_parser_omp_context_selector): Don't require score
argument to fit into shwi, just to be INTEGER_CST. Diagnose
negative score.
* parser.c (cp_parser_omp_context_selector): Don't require score
argument to fit into shwi, just to be INTEGER_CST. Diagnose
negative score.
* pt.c (tsubst_attribute): Likewise.
* c-c++-common/gomp/declare-variant-2.c: Add test for non-integral
score and for negative score.
* c-c++-common/gomp/declare-variant-3.c: Add test for zero score.
* g++.dg/gomp/declare-variant-8.C: Add test for negative and zero
scores.
From-SVN: r278204
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 11 | ||||
-rw-r--r-- | gcc/cp/pt.c | 14 |
3 files changed, 26 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ec053f3..c836859 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2019-11-14 Jakub Jelinek <jakub@redhat.com> + * parser.c (cp_parser_omp_context_selector): Don't require score + argument to fit into shwi, just to be INTEGER_CST. Diagnose + negative score. + * pt.c (tsubst_attribute): Likewise. + * parser.c (cp_parser_omp_context_selector): Rename CTX_PROPERTY_IDLIST to CTX_PROPERTY_NAME_LIST, add CTX_PROPERTY_ID. Use CTX_PROPERTY_ID for atomic_default_mem_order, only allow a single diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index be29a27..c473e7f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -40565,11 +40565,16 @@ cp_parser_omp_context_selector (cp_parser *parser, tree set, bool has_parms_p) if (score != error_mark_node) { score = fold_non_dependent_expr (score); - if (!value_dependent_expression_p (score) - && (!INTEGRAL_TYPE_P (TREE_TYPE (score)) - || !tree_fits_shwi_p (score))) + if (value_dependent_expression_p (score)) + properties = tree_cons (get_identifier (" score"), + score, properties); + else if (!INTEGRAL_TYPE_P (TREE_TYPE (score)) + || TREE_CODE (score) != INTEGER_CST) error_at (token->location, "score argument must be " "constant integer expression"); + else if (tree_int_cst_sgn (score) < 0) + error_at (token->location, "score argument must be " + "non-negative"); else properties = tree_cons (get_identifier (" score"), score, properties); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 307ae6e..84db3f9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11172,7 +11172,9 @@ tsubst_attribute (tree t, tree *decl_p, tree args, v = tsubst_expr (v, args, complain, in_decl, true); v = fold_non_dependent_expr (v); if (!INTEGRAL_TYPE_P (TREE_TYPE (v)) - || !tree_fits_shwi_p (v)) + || (TREE_PURPOSE (t3) == score + ? TREE_CODE (v) != INTEGER_CST + : !tree_fits_shwi_p (v))) { location_t loc = cp_expr_loc_or_loc (TREE_VALUE (t3), @@ -11189,6 +11191,16 @@ tsubst_attribute (tree t, tree *decl_p, tree args, "integer expression"); return NULL_TREE; } + else if (TREE_PURPOSE (t3) == score + && tree_int_cst_sgn (v) < 0) + { + location_t loc + = cp_expr_loc_or_loc (TREE_VALUE (t3), + match_loc); + error_at (loc, "score argument must be " + "non-negative"); + return NULL_TREE; + } TREE_VALUE (t3) = v; } } |