From: Chung-Lin Tang Date: Thu, 19 Aug 2021 08:17:02 +0000 (+0800) Subject: openacc: fix ICE for non-decl expression in non-contiguous array base-pointer X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1cc4392a404a6b819ab050a4e66c5ff7e6fbe3f;p=thirdparty%2Fgcc.git openacc: fix ICE for non-decl expression in non-contiguous array base-pointer Currently, we do not support cases like struct-members as the base-pointer for an OpenACC non-contiguous array. Mark such cases as unsupported in the C/C++ front-ends, instead of ICEing on them. gcc/c/ChangeLog: * c-typeck.cc (handle_omp_array_sections_1): Robustify non-contiguous array check and reject non-DECL base-pointer cases as unsupported. gcc/cp/ChangeLog: * semantics.cc (handle_omp_array_sections_1): Robustify non-contiguous array check and reject non-DECL base-pointer cases as unsupported. --- diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp index 9c7daa193a98..73b6bb1f78b8 100644 --- a/gcc/c/ChangeLog.omp +++ b/gcc/c/ChangeLog.omp @@ -1,3 +1,8 @@ +2021-08-19 Chung-Lin Tang + + * c-typeck.cc (handle_omp_array_sections_1): Robustify non-contiguous + array check and reject non-DECL base-pointer cases as unsupported. + 2021-02-02 Chung-Lin Tang * c-parser.cc (c_parser_declaration_or_fndef): Set diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 2965bd74cfc9..32bf33e80d69 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -13576,14 +13576,27 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, if (d_length == NULL_TREE || !integer_onep (d_length)) { if (ort == C_ORT_ACC) - non_contiguous = true; - else { + while (TREE_CODE (d) == TREE_LIST) + d = TREE_CHAIN (d); + if (DECL_P (d)) + { + /* Note that OpenACC does accept these kinds of + non-contiguous pointer based arrays. */ + non_contiguous = true; + break; + } error_at (OMP_CLAUSE_LOCATION (c), - "array section is not contiguous in %qs clause", + "base-pointer expression in %qs clause not " + "supported for non-contiguous arrays", omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } + + error_at (OMP_CLAUSE_LOCATION (c), + "array section is not contiguous in %qs clause", + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + return error_mark_node; } } } diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp index efda4eddf14a..bd0dbe8ba422 100644 --- a/gcc/cp/ChangeLog.omp +++ b/gcc/cp/ChangeLog.omp @@ -1,3 +1,8 @@ +2021-08-19 Chung-Lin Tang + + * semantics.cc (handle_omp_array_sections_1): Robustify non-contiguous + array check and reject non-DECL base-pointer cases as unsupported. + 2021-03-03 Chung-Lin Tang * decl2.cc (cp_omp_mappable_type_1): Allow fields with diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index daef4fb581e9..539bdca7eb0f 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -5396,9 +5396,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, return error_mark_node; } /* If there is a pointer type anywhere but in the very first - array-section-subscript, the array section could be non-contiguous. - Note that OpenACC does accept these kinds of non-contiguous pointer - based arrays. */ + array-section-subscript, the array section could be non-contiguous. */ if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND && TREE_CODE (TREE_CHAIN (t)) == TREE_LIST) @@ -5412,14 +5410,27 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, if (d_length == NULL_TREE || !integer_onep (d_length)) { if (ort == C_ORT_ACC) - non_contiguous = true; - else { + while (TREE_CODE (d) == TREE_LIST) + d = TREE_CHAIN (d); + if (DECL_P (d)) + { + /* Note that OpenACC does accept these kinds of + non-contiguous pointer based arrays. */ + non_contiguous = true; + break; + } error_at (OMP_CLAUSE_LOCATION (c), - "array section is not contiguous in %qs clause", + "base-pointer expression in %qs clause not " + "supported for non-contiguous arrays", omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } + + error_at (OMP_CLAUSE_LOCATION (c), + "array section is not contiguous in %qs clause", + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + return error_mark_node; } } }