2015-12-07 Jason Merrill <jason@redhat.com>
+ PR c++/68464
+ * cp-gimplify.c (cp_fold): Don't assume X has TREE_TYPE.
+ (cp_genericize): Don't do cp_fold_r here.
+ (cp_fold_function): New.
+ * cp-tree.h: Declare it.
+ * decl.c (finish_function): Call it and the pre-genericize plugin
+ before NRV processing.
+
PR c++/68170
* pt.c (maybe_new_partial_specialization): The injected-class-name
is not a new partial specialization.
return NULL;
}
+/* Fold ALL the trees! FIXME we should be able to remove this, but
+ apparently that still causes optimization regressions. */
+
+void
+cp_fold_function (tree fndecl)
+{
+ cp_walk_tree (&DECL_SAVED_TREE (fndecl), cp_fold_r, NULL, NULL);
+}
+
/* Perform any pre-gimplification lowering of C++ front end trees to
GENERIC. */
{
tree t;
- /* Fold ALL the trees! FIXME we should be able to remove this, but
- apparently that still causes optimization regressions. */
- cp_walk_tree (&DECL_SAVED_TREE (fndecl), cp_fold_r, NULL, NULL);
-
/* Fix up the types of parms passed by invisible reference. */
for (t = DECL_ARGUMENTS (fndecl); t; t = DECL_CHAIN (t))
if (TREE_ADDRESSABLE (TREE_TYPE (t)))
location_t loc;
bool rval_ops = true;
- if (!x || error_operand_p (x))
+ if (!x || x == error_mark_node)
return x;
if (processing_template_decl
- || (EXPR_P (x) && !TREE_TYPE (x)))
+ || (EXPR_P (x) && (!TREE_TYPE (x) || TREE_TYPE (x) == error_mark_node)))
return x;
/* Don't bother to cache DECLs or constants. */
extern void cxx_omp_finish_clause (tree, gimple_seq *);
extern bool cxx_omp_privatize_by_reference (const_tree);
extern bool cxx_omp_disregard_value_expr (tree, bool);
+extern void cp_fold_function (tree);
extern tree cp_fully_fold (tree);
/* in name-lookup.c */
the NRV transformation. */
maybe_save_function_definition (fndecl);
+ /* Invoke the pre-genericize plugin before we start munging things. */
+ if (!processing_template_decl)
+ invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl);
+
+ /* Perform delayed folding before NRV transformation. */
+ if (!processing_template_decl)
+ cp_fold_function (fndecl);
+
/* Set up the named return value optimization, if we can. Candidate
variables are selected in check_return_expr. */
if (current_function_return_value)
if (!processing_template_decl)
{
struct language_function *f = DECL_SAVED_FUNCTION_DATA (fndecl);
- invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl);
cp_genericize (fndecl);
/* Clear out the bits we don't need. */
f->x_current_class_ptr = NULL;