public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/100859] [12 Regression][OpenMP] ICE in tsubst_omp_clauses, at cp/pt.c:17520 since r12-1108-g9a5de4d5af1c10a8
Date: Wed, 02 Jun 2021 09:51:13 +0000	[thread overview]
Message-ID: <bug-100859-4-eiZWiezld9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100859-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100859

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
WIP testcase:
struct S {
  S () {}
};

struct W {
  S c[10];
  W () {
#pragma omp task affinity (iterator (i = 0 : 10 : 1): c[i])
    ;
#pragma omp task depend (iterator (i = 0 : 10 : 1), inout: c[i])
    ;
#pragma omp task affinity (this[0])
    ;
#pragma omp task depend (inout: this[0])
    ;
#pragma omp taskwait
  }
};

template <typename T>
struct U {
  T c[10];
  U () {
#pragma omp task affinity (iterator (i = 0 : 10 : 1): c[i])
    ;
#pragma omp task depend (iterator (i = 0 : 10 : 1), inout: c[i])
    ;
#pragma omp task affinity (this[0])
    ;
#pragma omp task depend (inout: this[0])
    ;
#pragma omp taskwait
  }
};

struct V : public U<S> {
  V () : U<S> () {}
};

W w;
V v;

and WIP patch:
--- gcc/cp/semantics.c.jj       2021-06-02 10:07:47.633826543 +0200
+++ gcc/cp/semantics.c  2021-06-02 11:35:39.490212873 +0200
@@ -4968,7 +4968,11 @@ handle_omp_array_sections_1 (tree c, tre
          if (REFERENCE_REF_P (t))
            t = TREE_OPERAND (t, 0);
        }
-      if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
+      if (TREE_CODE (t) == FIELD_DECL
+         && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
+             || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND))
+       ret = finish_non_static_data_member (t, NULL_TREE, NULL_TREE);
+      else if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
        {
          if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
            return NULL_TREE;
@@ -4985,7 +4989,9 @@ handle_omp_array_sections_1 (tree c, tre
       else if (ort == C_ORT_OMP
               && TREE_CODE (t) == PARM_DECL
               && DECL_ARTIFICIAL (t)
-              && DECL_NAME (t) == this_identifier)
+              && DECL_NAME (t) == this_identifier
+              && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
+              && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
        {
          error_at (OMP_CLAUSE_LOCATION (c),
                    "%<this%> allowed in OpenMP only in %<declare simd%>"
@@ -7468,7 +7474,6 @@ finish_omp_clauses (tree clauses, enum c
            }
          goto handle_field_decl;

-       case OMP_CLAUSE_AFFINITY:
        case OMP_CLAUSE_DEPEND:
          t = OMP_CLAUSE_DECL (c);
          if (t == NULL_TREE)
@@ -7477,13 +7482,15 @@ finish_omp_clauses (tree clauses, enum c
                          == OMP_CLAUSE_DEPEND_SOURCE);
              break;
            }
-         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
-             && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK)
+         if (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK)
            {
              if (cp_finish_omp_clause_depend_sink (c))
                remove = true;
              break;
            }
+         /* FALLTHRU */
+       case OMP_CLAUSE_AFFINITY:
+         t = OMP_CLAUSE_DECL (c);
          if (TREE_CODE (t) == TREE_LIST
              && TREE_PURPOSE (t)
              && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
@@ -7543,11 +7550,9 @@ finish_omp_clauses (tree clauses, enum c
                   && TREE_CODE (TREE_OPERAND (t, 1)) == FIELD_DECL
                   && DECL_BIT_FIELD (TREE_OPERAND (t, 1)))
            {
-             gcc_assert (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
-                         || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY);
              error_at (OMP_CLAUSE_LOCATION (c),
                        "bit-field %qE in %qs clause", t,
-                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
              remove = true;
            }
          else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
--- gcc/cp/pt.c.jj      2021-05-31 10:11:15.149978907 +0200
+++ gcc/cp/pt.c 2021-06-02 10:41:31.319178655 +0200
@@ -17399,6 +17399,7 @@ tsubst_omp_clauses (tree clauses, enum c
        case OMP_CLAUSE_COPYPRIVATE:
        case OMP_CLAUSE_UNIFORM:
        case OMP_CLAUSE_DEPEND:
+       case OMP_CLAUSE_AFFINITY:
        case OMP_CLAUSE_FROM:
        case OMP_CLAUSE_TO:
        case OMP_CLAUSE_MAP:

There are still ICEs on it though (on the non-template case).

  parent reply	other threads:[~2021-06-02  9:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 15:25 [Bug c++/100859] New: ICE in tsubst_omp_clauses, at cp/pt.c:17520 asolokha at gmx dot com
2021-06-02  6:29 ` [Bug c++/100859] [12 Regression] ICE in tsubst_omp_clauses, at cp/pt.c:17520 since r12-1108-g9a5de4d5af1c10a8 marxin at gcc dot gnu.org
2021-06-02  7:40 ` [Bug c++/100859] [12 Regression][OpenMP] " burnus at gcc dot gnu.org
2021-06-02  8:01 ` rguenth at gcc dot gnu.org
2021-06-02  8:44 ` jakub at gcc dot gnu.org
2021-06-02  9:51 ` jakub at gcc dot gnu.org [this message]
2021-06-02  9:57 ` jakub at gcc dot gnu.org
2021-06-02 12:16 ` jakub at gcc dot gnu.org
2021-06-03  8:46 ` cvs-commit at gcc dot gnu.org
2021-06-04  9:22 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-100859-4-eiZWiezld9@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).