]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Don't ICE on detach clause with erroneous decl [PR98742]
authorJakub Jelinek <jakub@redhat.com>
Wed, 20 Jan 2021 07:35:20 +0000 (08:35 +0100)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Fri, 22 Jan 2021 16:35:02 +0000 (08:35 -0800)
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)

gcc/cp/ChangeLog.omp
gcc/cp/semantics.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/task-detach-2.c [new file with mode: 0644]

index f071ef61b17081c34c6b51df2b743906f8a702ba..559eb47f12a11be0d8dcdf3cf51fe28a8013000c 100644 (file)
@@ -1,3 +1,13 @@
+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
index 86d5d464a325ceffb0e53fa1ab5decb6a1f3fadd..b4544f78aa7df0b803809689f63665b67efb1cb2 100644 (file)
@@ -7350,12 +7350,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"))))
                {
index 457ce6e38cfe2d322041be895ceb70d073b2a30a..a00749e988e6b250c5eb38e02fe5a4d9f7913d5a 100644 (file)
@@ -1,3 +1,11 @@
+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
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 (file)
index 0000000..2d197d2
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c++/98742 */
+/* { dg-do compile } */
+
+void
+foo ()
+{
+#pragma omp task detach(0)     /* { dg-error "before numeric constant" } */
+  ;
+}