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 <jakub@redhat.com>
PR c++/98742
* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_DETACH>: 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.
(cherry picked from commit
7ab1abf3b82a3bcfff9b7bc596166fef6a0d83ab)
+2021-01-22 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ Backport from mainline
+ 2021-01-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/98742
+ * semantics.c (finish_omp_clauses) <case OMP_CLAUSE_DETACH>: If
+ error_operand_p, remove clause without further checking. Check
+ for non-NULL TYPE_NAME.
+
2021-01-22 Kwok Cheung Yeung <kcy@codesourcery.com>
Backport from mainline
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"))))
{
+2021-01-22 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ Backport from mainline
+ 2021-01-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/98742
+ * c-c++-common/gomp/task-detach-2.c: New test.
+
2021-01-22 Kwok Cheung Yeung <kcy@codesourcery.com>
Backport from mainline
--- /dev/null
+/* PR c++/98742 */
+/* { dg-do compile } */
+
+void
+foo ()
+{
+#pragma omp task detach(0) /* { dg-error "before numeric constant" } */
+ ;
+}