From 7ab1abf3b82a3bcfff9b7bc596166fef6a0d83ab Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 20 Jan 2021 08:35:20 +0100 Subject: [PATCH] openmp: Don't ICE on detach clause with erroneous decl [PR98742] Similarly to how we handle erroneous operands to e.g. allocate clause, this change just removes those clauses instead of accessing TYPE_MAIN_VARIANT of its type, which doesn't work on error_mark_node. Also, just for good measure, bails out if TYPE_NAME is NULL. 2021-01-20 Jakub Jelinek PR c++/98742 * semantics.c (finish_omp_clauses) : If error_operand_p, remove clause without further checking. Check for non-NULL TYPE_NAME. * c-c++-common/gomp/task-detach-2.c: New test. --- gcc/cp/semantics.c | 6 ++++++ gcc/testsuite/c-c++-common/gomp/task-detach-2.c | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/gomp/task-detach-2.c diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c8a6283b120..244fc70d02d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7430,12 +7430,18 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) remove = true; break; } + else if (error_operand_p (t)) + { + remove = true; + break; + } else { tree type = TYPE_MAIN_VARIANT (TREE_TYPE (t)); if (!type_dependent_expression_p (t) && (!INTEGRAL_TYPE_P (type) || TREE_CODE (type) != ENUMERAL_TYPE + || TYPE_NAME (type) == NULL_TREE || (DECL_NAME (TYPE_NAME (type)) != get_identifier ("omp_event_handle_t")))) { diff --git a/gcc/testsuite/c-c++-common/gomp/task-detach-2.c b/gcc/testsuite/c-c++-common/gomp/task-detach-2.c new file mode 100644 index 00000000000..2d197d2fb3e --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/task-detach-2.c @@ -0,0 +1,9 @@ +/* PR c++/98742 */ +/* { dg-do compile } */ + +void +foo () +{ +#pragma omp task detach(0) /* { dg-error "before numeric constant" } */ + ; +} -- 2.30.2