public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9506] c++: Fix up VEC_INIT_EXPR gimplification after r12-7069
@ 2023-05-03  9:46 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-05-03  9:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a97d3aa16a8d4b2afe1970d3fb69504166c3bd4a

commit r12-9506-ga97d3aa16a8d4b2afe1970d3fb69504166c3bd4a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed May 3 10:38:04 2023 +0200

    c++: Fix up VEC_INIT_EXPR gimplification after r12-7069
    
    During patch backporting, I've noticed that while most cp_walk_tree calls
    with cp_fold_r callback callers were changed from &pset to cp_fold_data
    &data, the VEC_INIT_EXPR gimplifications has not, so it still passes just
    address of a hash_set<tree> and so if during the folding we ever touch
    data->genericize, we use uninitialized data there.
    
    The following patch changes it to do the same thing as cp_fold_function
    because the VEC_INIT_EXPR gimplifications will happen on function bodies
    only.
    
    2023-05-03  Jakub Jelinek  <jakub@redhat.com>
    
            * cp-gimplify.cc (cp_fold_data): Move definition earlier.
            (cp_gimplify_expr): Pass address of genericize = true
            constructed data rather than &pset to cp_walk_tree with cp_fold_r.
    
    (cherry picked from commit 8d193b12d6f07ae0196db8296a49c881c1638c01)

Diff:
---
 gcc/cp/cp-gimplify.cc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index 71c55e18557..07620b4e01b 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -43,6 +43,14 @@ along with GCC; see the file COPYING3.  If not see
 #include "omp-general.h"
 #include "opts.h"
 
+struct cp_fold_data
+{
+  hash_set<tree> pset;
+  bool genericize; // called from cp_fold_function?
+
+  cp_fold_data (bool g): genericize (g) {}
+};
+
 /* Forward declarations.  */
 
 static tree cp_genericize_r (tree *, int *, void *);
@@ -487,8 +495,8 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 	*expr_p = expand_vec_init_expr (NULL_TREE, *expr_p,
 					tf_warning_or_error);
 
-	hash_set<tree> pset;
-	cp_walk_tree (expr_p, cp_fold_r, &pset, NULL);
+	cp_fold_data data (/*genericize*/true);
+	cp_walk_tree (expr_p, cp_fold_r, &data, NULL);
 	cp_genericize_tree (expr_p, false);
 	copy_if_shared (expr_p);
 	ret = GS_OK;
@@ -963,14 +971,6 @@ struct cp_genericize_data
      in fold-const, we need to perform this before transformation to
      GIMPLE-form.  */
 
-struct cp_fold_data
-{
-  hash_set<tree> pset;
-  bool genericize; // called from cp_fold_function?
-
-  cp_fold_data (bool g): genericize (g) {}
-};
-
 static tree
 cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_)
 {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-03  9:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-03  9:46 [gcc r12-9506] c++: Fix up VEC_INIT_EXPR gimplification after r12-7069 Jakub Jelinek

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).