static tree
cp_make_fname_decl (location_t loc, tree id, int type_dep)
{
- const char *const name = (type_dep && processing_template_decl
+ const char *const name = (type_dep && in_template_function ()
? NULL : fname_as_string (type_dep));
tree type;
tree init = cp_fname_init (name, &type);
if (name)
free (CONST_CAST (char *, name));
- TREE_STATIC (decl) = 1;
+ /* As we're using pushdecl_with_scope, we must set the context. */
+ DECL_CONTEXT (decl) = current_function_decl;
+
TREE_READONLY (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
+ DECL_DECLARED_CONSTEXPR_P (decl) = 1;
+ TREE_STATIC (decl) = 1;
TREE_USED (decl) = 1;
+ if (init)
+ {
+ SET_DECL_VALUE_EXPR (decl, init);
+ DECL_HAS_VALUE_EXPR_P (decl) = 1;
+ /* For decl_constant_var_p. */
+ DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = 1;
+ }
+
if (current_function_decl)
{
DECL_CONTEXT (decl) = current_function_decl;
decl = pushdecl_outermost_localscope (decl);
- cp_finish_decl (decl, init, /*init_const_expr_p=*/false, NULL_TREE,
- LOOKUP_ONLYCONVERTING);
+ if (decl != error_mark_node)
+ add_decl_expr (decl);
}
else
{
DECL_THIS_STATIC (decl) = true;
- pushdecl_top_level_and_finish (decl, init);
+ pushdecl_top_level_and_finish (decl, NULL_TREE);
}
return decl;
init = NULL_TREE;
release_tree_vector (cleanups);
}
- else if (!DECL_PRETTY_FUNCTION_P (decl))
+ else
{
+ gcc_assert (!DECL_PRETTY_FUNCTION_P (decl));
/* Deduce array size even if the initializer is dependent. */
maybe_deduce_size_from_array_init (decl, init);
/* And complain about multiple initializers. */