]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Revert "Fix template case of non-static member access inside member functions"
authorChung-Lin Tang <cltang@codesourcery.com>
Wed, 26 May 2021 11:11:49 +0000 (19:11 +0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Sat, 29 May 2021 19:53:18 +0000 (03:53 +0800)
This reverts commit 56314e382995ebbf35f77b9a2542b5411b9ae755.

gcc/cp/semantics.c
gcc/gimplify.c
gcc/testsuite/g++.dg/gomp/target-this-3.C
gcc/testsuite/g++.dg/gomp/target-this-4.C
gcc/testsuite/g++.dg/gomp/target-this-5.C [deleted file]
libgomp/testsuite/libgomp.c++/target-this-5.C [deleted file]

index 2eeab999841d5a7306653f0e8c1b8a17631b8606..6a71338fde9efe649370f11f68a5c068a3d4513c 100644 (file)
@@ -6597,7 +6597,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
   bool order_seen = false;
   bool schedule_seen = false;
   bool oacc_async = false;
-  bool indirect_ref_p = false;
   bool indir_component_ref_p = false;
   tree last_iterators = NULL_TREE;
   bool last_iterators_remove = false;
@@ -7846,14 +7845,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
              indir_component_ref_p = true;
              STRIP_NOPS (t);
            }
-         indirect_ref_p = false;
-         if ((ort == C_ORT_ACC || ort == C_ORT_OMP)
-             && INDIRECT_REF_P (t))
-           {
-             t = TREE_OPERAND (t, 0);
-             indirect_ref_p = true;
-             STRIP_NOPS (t);
-           }
          if (TREE_CODE (t) == COMPONENT_REF
              && ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP
                  || ort == C_ORT_ACC)
@@ -7889,12 +7880,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
                      break;
                    }
                  t = TREE_OPERAND (t, 0);
-                 if (INDIRECT_REF_P (t))
-                   {
-                     t = TREE_OPERAND (t, 0);
-                     indir_component_ref_p = true;
-                     STRIP_NOPS (t);
-                   }
                }
              if (remove)
                break;
@@ -7958,7 +7943,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
                       || (OMP_CLAUSE_MAP_KIND (c)
                           != GOMP_MAP_FIRSTPRIVATE_POINTER))
                   && !indir_component_ref_p
-                  && !indirect_ref_p
                   && !cxx_mark_addressable (t))
            remove = true;
          else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
@@ -8053,8 +8037,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
            }
          else
            {
-             if (!indirect_ref_p && !indir_component_ref_p)
-               bitmap_set_bit (&map_head, DECL_UID (t));
+             bitmap_set_bit (&map_head, DECL_UID (t));
              if (t != OMP_CLAUSE_DECL (c)
                  && TREE_CODE (OMP_CLAUSE_DECL (c)) == COMPONENT_REF)
                bitmap_set_bit (&map_field_head, DECL_UID (t));
@@ -9115,12 +9098,9 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p)
          tree closure = DECL_ARGUMENTS (current_function_decl);
          tree c = build_omp_clause (loc, OMP_CLAUSE_MAP);
          OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TO);
-         OMP_CLAUSE_DECL (c)
-           = build_indirect_ref (loc, closure, RO_UNARY_STAR);
+         OMP_CLAUSE_DECL (c) = build_simple_mem_ref (closure);
          OMP_CLAUSE_SIZE (c)
-           = (processing_template_decl
-              ? NULL_TREE
-              : TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (closure))));
+           = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (closure)));
 
          tree c2 = build_omp_clause (loc, OMP_CLAUSE_MAP);
          OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_FIRSTPRIVATE_POINTER);
@@ -9140,8 +9120,7 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p)
              /* Transform *this into *__closure->this in maps.  */
              tree this_map = *explicit_this_deref_map;
              OMP_CLAUSE_DECL (this_map)
-               = build_indirect_ref (loc, omp_target_this_expr, RO_UNARY_STAR);
-
+               = build_simple_mem_ref (omp_target_this_expr);
              tree nc = OMP_CLAUSE_CHAIN (this_map);
              gcc_assert (OMP_CLAUSE_CODE (nc) == OMP_CLAUSE_MAP
                          && (OMP_CLAUSE_MAP_KIND (nc)
@@ -9161,11 +9140,9 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p)
              tree c3 = build_omp_clause (loc, OMP_CLAUSE_MAP);
              OMP_CLAUSE_SET_MAP_KIND (c3, GOMP_MAP_TOFROM);
              OMP_CLAUSE_DECL (c3)
-               = build_indirect_ref (loc, omp_target_this_expr, RO_UNARY_STAR);
+               = build_simple_mem_ref (omp_target_this_expr);
              OMP_CLAUSE_SIZE (c3)
-               = (processing_template_decl
-                  ? NULL_TREE
-                  : TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (omp_target_this_expr))));
+               = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (omp_target_this_expr)));
 
              tree c4 = build_omp_clause (loc, OMP_CLAUSE_MAP);
              OMP_CLAUSE_SET_MAP_KIND (c4, GOMP_MAP_ALWAYS_POINTER);
@@ -9187,12 +9164,9 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p)
            {
              tree c = build_omp_clause (loc, OMP_CLAUSE_MAP);
              OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TOFROM);
-             OMP_CLAUSE_DECL (c)
-               = build_indirect_ref (loc, omp_target_this_expr, RO_UNARY_STAR);
+             OMP_CLAUSE_DECL (c) = build_simple_mem_ref (omp_target_this_expr);
              OMP_CLAUSE_SIZE (c)
-               = (processing_template_decl
-                  ? NULL_TREE
-                  : TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (omp_target_this_expr))));
+               = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (omp_target_this_expr)));
 
              tree c2 = build_omp_clause (loc, OMP_CLAUSE_MAP);
              OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_FIRSTPRIVATE_POINTER);
@@ -9274,7 +9248,8 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p)
            tree c = build_omp_clause (loc, OMP_CLAUSE_MAP);
            OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_ALLOC);
            OMP_CLAUSE_DECL (c)
-             = build_indirect_ref (loc, ptr_member, RO_UNARY_STAR);
+             = build2 (MEM_REF, char_type_node, ptr_member,
+                       build_int_cst (build_pointer_type (char_type_node), 0));
            OMP_CLAUSE_SIZE (c) = size_zero_node;
            OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1;
 
index 8720f876359e5ebd46679eabec25fcfd0617026a..e233db2bd552d007ac668864898056c87d7de992 100644 (file)
@@ -9321,7 +9321,6 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
                        {
                          indir_p = true;
                          decl = TREE_OPERAND (decl, 0);
-                         STRIP_NOPS (decl);
                        }
                      if (TREE_CODE (decl) == INDIRECT_REF
                          && DECL_P (TREE_OPERAND (decl, 0))
@@ -9733,24 +9732,6 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
                  break;
                }
 
-             /* If this was of the form map(*pointer_to_struct), then the
-                'pointer_to_struct' DECL should be considered deref'ed.  */
-             if ((OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ALLOC
-                  || GOMP_MAP_COPY_TO_P (OMP_CLAUSE_MAP_KIND (c))
-                  || GOMP_MAP_COPY_FROM_P (OMP_CLAUSE_MAP_KIND (c)))
-                 && INDIRECT_REF_P (orig_decl)
-                 && DECL_P (TREE_OPERAND (orig_decl, 0))
-                 && TREE_CODE (TREE_TYPE (orig_decl)) == RECORD_TYPE)
-               {
-                 tree ptr = TREE_OPERAND (orig_decl, 0);
-                 if (!struct_deref_set || !struct_deref_set->contains (ptr))
-                   {
-                     if (!struct_deref_set)
-                       struct_deref_set = new hash_set<tree> ();
-                     struct_deref_set->add (ptr);
-                   }
-               }
-
              if (!remove
                  && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ALWAYS_POINTER
                  && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH
index 08568f9284c1cb481fd25648512198672fb9ee0d..a450b3723e5c5b0fe739a677abe23f35159074dd 100644 (file)
@@ -102,4 +102,4 @@ int main (void)
 
 /* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(tofrom:\*this \[len: [0-9]+\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\) map\(alloc:\*_[0-9]+ \[pointer assign, zero-length array section, bias: 0\]\) map\(attach:this->refptr \[bias: 0\]\) map\(from:mapped \[len: [0-9]+\]\) map\(alloc:\*_[0-9+] \[len: 0\]\) firstprivate\(n\)} "gimple" } } */
 
-/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(tofrom:\*this \[len: [0-9]+\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\) map\(attach_zero_length_array_section:this->ptr \[bias: 0\]\) map\(from:mapped \[len: [0-9]+\]\) map\(alloc:\*_[0-9]+ \[len: 0\]\) firstprivate\(n\)} "gimple" } } */
+/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(tofrom:\*this \[len: [0-9]+\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\) map\(attach_zero_length_array_section:this->ptr \[bias: 0\]\) map\(from:mapped \[len: [0-9]+\]\) map\(alloc:MEM.* \[len: 0\]\) firstprivate\(n\)} "gimple" } } */
index 3b2d5811350bfe1efb36e1f3f75e9b10c13b2565..af23cbb90231ea05dd749704806f1280db9cf60b 100644 (file)
@@ -102,6 +102,6 @@ int main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(to:\*__closure \[len: [0-9]+\]\) map\(firstprivate:__closure \[pointer assign, bias: 0\]\) map\(struct:\*__closure \[len: 1\]\) map\(alloc:__closure->__this \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: [0-9]+\]\) map\(always_pointer:__closure->__this \[pointer assign, bias: 0\]\) map\(attach_zero_length_array_section:_[0-9]+->ptr \[bias: 0\]\) map\(from:mapped \[len: 1\]\) map\(alloc:\*_[0-9]+ \[len: 0\]\) firstprivate\(n\) map\(alloc:MEM.* \[len: 0\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\)} "gimple" } } */
+/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(to:\*__closure \[len: [0-9]+\]\) map\(firstprivate:__closure \[pointer assign, bias: 0\]\) map\(struct:\*__closure \[len: 1\]\) map\(alloc:__closure->__this \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: [0-9]+\]\) map\(always_pointer:__closure->__this \[pointer assign, bias: 0\]\) map\(attach_zero_length_array_section:_[0-9]+->ptr \[bias: 0\]\) map\(from:mapped \[len: 1\]\) map\(alloc:MEM.* \[len: 0\]\) firstprivate\(n\) map\(alloc:MEM.* \[len: 0\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\)} "gimple" } } */
 
 /* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(to:\*__closure \[len: [0-9]+\]\) map\(firstprivate:__closure \[pointer assign, bias: 0\]\) map\(struct:\*__closure \[len: 1\]\) map\(alloc:__closure->__this \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: [0-9]+\]\) map\(always_pointer:__closure->__this \[pointer assign, bias: 0\]\) map\(alloc:\*_[0-9]+ \[pointer assign, zero-length array section, bias: 0\]\) map\(attach:_[0-9]+->refptr \[bias: 0\]\) map\(from:mapped \[len: [0-9]+\]\) map\(alloc:\*_[0-9]+ \[len: 0\]\) firstprivate\(n\) map\(alloc:MEM.* \[len: 0\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\)} "gimple" } } */
diff --git a/gcc/testsuite/g++.dg/gomp/target-this-5.C b/gcc/testsuite/g++.dg/gomp/target-this-5.C
deleted file mode 100644 (file)
index a9ac74b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// { dg-do compile }
-// { dg-additional-options "-fdump-tree-gimple" }
-extern "C" void abort ();
-
-template<typename T>
-struct S
-{
-  T a, b, c, d;
-
-  T sum (void)
-  {
-    T val = 0;
-    val += a + b + this->c + this->d;
-    return val;
-  }
-
-  T sum_offload (void)
-  {
-    T val = 0;
-    #pragma omp target map(val)
-    val += a + b + this->c + this->d;
-    return val;
-  }
-};
-
-int main (void)
-{
-  S<int> s = { 1, 2, 3, 4 };
-  if (s.sum () != s.sum_offload ())
-    abort ();
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump {map\(tofrom:\*this \[len: [0-9]+\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\)} "gimple" } } */
diff --git a/libgomp/testsuite/libgomp.c++/target-this-5.C b/libgomp/testsuite/libgomp.c++/target-this-5.C
deleted file mode 100644 (file)
index e71c566..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-extern "C" void abort ();
-
-template<typename T>
-struct S
-{
-  T a, b, c, d;
-
-  T sum (void)
-  {
-    T val = 0;
-    val += a + b + this->c + this->d;
-    return val;
-  }
-
-  T sum_offload (void)
-  {
-    T val = 0;
-    #pragma omp target map(val)
-    val += a + b + this->c + this->d;
-    return val;
-  }
-};
-
-int main (void)
-{
-  S<int> s = { 1, 2, 3, 4 };
-  if (s.sum () != s.sum_offload ())
-    abort ();
-  return 0;
-}