https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106829
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:f755e367117ca43c96235ef47d4915c3746a3483 commit r12-8883-gf755e367117ca43c96235ef47d4915c3746a3483 Author: Jakub Jelinek <ja...@redhat.com> Date: Wed Sep 7 08:54:13 2022 +0200 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 <ja...@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. (cherry picked from commit e90af965e5c858ba02c0cdfbac35d0a19da1c2f6)