]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Avoid ICE on depend clause on depobj OpenMP construct [PR98072]
authorJakub Jelinek <jakub@redhat.com>
Tue, 1 Dec 2020 20:41:44 +0000 (21:41 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 6 Jan 2021 09:38:35 +0000 (10:38 +0100)
Since r11-5430 we ICE on the following testcase.  When parsing the depobj
directive we don't really use cp_parser_omp_all_clauses routine which ATM
disables generation of location wrappers and the newly added assertion
that there are no location wrappers thus triggers.

Fixed by adding the location wrappers suppression sentinel.

Longer term, we should handle location wrappers inside of OpenMP clauses.

2020-12-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/98072
* parser.c (cp_parser_omp_depobj): Suppress location wrappers when
parsing depend clause.

* c-c++-common/gomp/depobj-2.c: New test.

(cherry picked from commit 91ddf867a57b028ab322b737ea8355d5a472cd44)

gcc/cp/parser.c
gcc/testsuite/c-c++-common/gomp/depobj-2.c [new file with mode: 0644]

index cac1133d6f4381ff32ff2e1bce3175f3770a3112..c935ff582d3da6844f0934fe4a8136b313a9714f 100644 (file)
@@ -38206,6 +38206,8 @@ cp_parser_omp_depobj (cp_parser *parser, cp_token *pragma_tok)
       cp_lexer_consume_token (parser->lexer);
       if (!strcmp ("depend", p))
        {
+         /* Don't create location wrapper nodes within the depend clause.  */
+         auto_suppress_location_wrappers sentinel;
          clause = cp_parser_omp_clause_depend (parser, NULL_TREE, c_loc);
          if (clause)
            clause = finish_omp_clauses (clause, C_ORT_OMP);
diff --git a/gcc/testsuite/c-c++-common/gomp/depobj-2.c b/gcc/testsuite/c-c++-common/gomp/depobj-2.c
new file mode 100644 (file)
index 0000000..d06910c
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c++/98072 */
+
+typedef struct __attribute__((__aligned__ (sizeof (void *)))) omp_depend_t {
+  char __omp_depend_t__[2 * sizeof (void *)];
+} omp_depend_t;
+
+void
+foo (int *x, omp_depend_t *y, int z)
+{
+  #pragma omp depobj (*y) depend (in: x[z])
+}