#include "cgraph.h"
#include "omp-general.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 *);
init, VEC_INIT_EXPR_VALUE_INIT (*expr_p),
from_array,
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;
GIMPLE-form. */
static tree
-cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data)
+cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_)
{
- tree stmt;
- enum tree_code code;
+ cp_fold_data *data = (cp_fold_data*)data_;
+ tree stmt = *stmt_p;
+ enum tree_code code = TREE_CODE (stmt);
+
+ switch (code)
+ {
+ case VAR_DECL:
+ /* In initializers replace anon union artificial VAR_DECLs
+ with their DECL_VALUE_EXPRs, as nothing will do it later. */
+ if (DECL_ANON_UNION_VAR_P (stmt) && !data->genericize)
+ {
+ *stmt_p = stmt = unshare_expr (DECL_VALUE_EXPR (stmt));
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
*stmt_p = stmt = cp_fold (*stmt_p);
- if (((hash_set<tree> *) data)->add (stmt))
+ if (data->pset.add (stmt))
{
/* Don't walk subtrees of stmts we've already walked once, otherwise
we can have exponential complexity with e.g. lots of nested
void
cp_fold_function (tree fndecl)
{
- hash_set<tree> pset;
- cp_walk_tree (&DECL_SAVED_TREE (fndecl), cp_fold_r, &pset, NULL);
+ cp_fold_data data (/*genericize*/true);
+ cp_walk_tree (&DECL_SAVED_TREE (fndecl), cp_fold_r, &data, NULL);
}
/* Turn SPACESHIP_EXPR EXPR into GENERIC. */
if (processing_template_decl)
return x;
x = cp_fully_fold (x);
- hash_set<tree> pset;
- cp_walk_tree (&x, cp_fold_r, &pset, NULL);
+ cp_fold_data data (/*genericize*/false);
+ cp_walk_tree (&x, cp_fold_r, &data, NULL);
return x;
}