From: Jakub Jelinek Date: Tue, 1 Sep 2020 07:17:58 +0000 (+0200) Subject: openmp: Check for PARM_DECL before using C_ARRAY_PARAMETER or DECL_ARRAY_PARAMETER_P... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a37b0cccf4965f13006d2928f57a71e46e341cf8;p=gcc.git openmp: Check for PARM_DECL before using C_ARRAY_PARAMETER or DECL_ARRAY_PARAMETER_P [PR96867] The C++ macro performs a PARM_DECL_CHECK, so will ICE if not tested on a PARM_DECL, C_ARRAY_PARAMETER doesn't, but probably should, otherwise it is testing e.g. C_DECL_VARIABLE_SIZE on VAR_DECLs. 2020-09-01 Jakub Jelinek PR c++/96867 * c-typeck.c (handle_omp_array_sections_1): Test C_ARRAY_PARAMETER only on PARM_DECLs. * semantics.c (handle_omp_array_sections_1): Test DECL_ARRAY_PARAMETER_P only on PARM_DECLs. * c-c++-common/gomp/pr96867.c: New test. --- diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index e158d236501..bb27099bfe1 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -13298,7 +13298,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, { if (length == NULL_TREE) { - if (C_ARRAY_PARAMETER (ret)) + if (TREE_CODE (ret) == PARM_DECL && C_ARRAY_PARAMETER (ret)) error_at (OMP_CLAUSE_LOCATION (c), "for array function parameter length expression " "must be specified"); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7f861fde7d6..107d39ddb0e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5083,7 +5083,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, { if (length == NULL_TREE) { - if (DECL_ARRAY_PARAMETER_P (ret)) + if (TREE_CODE (ret) == PARM_DECL && DECL_ARRAY_PARAMETER_P (ret)) error_at (OMP_CLAUSE_LOCATION (c), "for array function parameter length expression " "must be specified"); diff --git a/gcc/testsuite/c-c++-common/gomp/pr96867.c b/gcc/testsuite/c-c++-common/gomp/pr96867.c new file mode 100644 index 00000000000..f55d9cf9960 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr96867.c @@ -0,0 +1,9 @@ +/* PR c++/96867 */ + +int *v; + +void +foo (int x) +{ + #pragma omp target update to (x, v[:]) /* { dg-error "for pointer type length expression must be specified" } */ +}