openmp: Fix handling of target constructs in static member functions [PR106829]
authorJakub Jelinek <jakub@redhat.com>
Wed, 7 Sep 2022 06:54:13 +0000 (08:54 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 7 Sep 2022 06:54:13 +0000 (08:54 +0200)
commite90af965e5c858ba02c0cdfbac35d0a19da1c2f6
tree4b3511c43b702dbd6ee42fa64d123c8a00f1605f
parent572f5e1bc68e131b25cd2d5ba231e932f5038904
openmp: Fix handling of target constructs in static member functions [PR106829]

Just calling current_nonlambda_class_type in static member functions returns
non-NULL, but something that isn't *this and if unlucky can match part of the
IL and can be added to target clauses.
      if (DECL_NONSTATIC_MEMBER_P (decl)
          && current_class_ptr)
is a guard used elsewhere (in check_accessibility_of_qualified_id).

2022-09-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/106829
* semantics.cc (finish_omp_target_clauses): If current_function_decl
isn't a nonstatic member function, don't set data.current_object to
non-NULL.

* g++.dg/gomp/pr106829.C: New test.
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/gomp/pr106829.C [new file with mode: 0644]