Hi! 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.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2020-09-01 Jakub Jelinek <ja...@redhat.com> 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. --- gcc/c/c-typeck.c.jj 2020-08-25 21:13:54.832897428 +0200 +++ gcc/c/c-typeck.c 2020-08-31 15:06:10.143426584 +0200 @@ -13298,7 +13298,7 @@ handle_omp_array_sections_1 (tree c, tre { 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"); --- gcc/cp/semantics.c.jj 2020-08-31 14:10:15.983919186 +0200 +++ gcc/cp/semantics.c 2020-08-31 15:05:47.528753277 +0200 @@ -5083,7 +5083,7 @@ handle_omp_array_sections_1 (tree c, tre { 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"); --- gcc/testsuite/c-c++-common/gomp/pr96867.c.jj 2020-08-31 15:07:29.271283504 +0200 +++ gcc/testsuite/c-c++-common/gomp/pr96867.c 2020-08-31 15:07:13.429512357 +0200 @@ -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" } */ +} Jakub