@@ -1563,6 +1563,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
prepend_one_attribute_pragma (&attr_list,
Linker_Section_Pragma (gnat_entity));
+ /* Do not initialize Out parameters with -ftrivial-auto-var-init. */
+ if (kind == E_Out_Parameter)
+ prepend_one_attribute
+ (&attr_list, ATTR_MACHINE_ATTRIBUTE,
+ get_identifier ("uninitialized"), NULL_TREE,
+ gnat_entity);
+
/* Now create the variable or the constant and set various flags. */
gnu_decl
= create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type,
@@ -107,6 +107,7 @@ static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
static tree handle_flatten_attribute (tree *, tree, tree, int, bool *);
static tree handle_used_attribute (tree *, tree, tree, int, bool *);
+static tree handle_uninitialized_attribute (tree *, tree, tree, int, bool *);
static tree handle_cold_attribute (tree *, tree, tree, int, bool *);
static tree handle_hot_attribute (tree *, tree, tree, int, bool *);
static tree handle_simd_attribute (tree *, tree, tree, int, bool *);
@@ -214,6 +215,8 @@ static const attribute_spec gnat_internal_attributes[] =
handle_flatten_attribute, NULL },
{ "used", 0, 0, true, false, false, false,
handle_used_attribute, NULL },
+ { "uninitialized",0, 0, true, false, false, false,
+ handle_uninitialized_attribute, NULL },
{ "cold", 0, 0, true, false, false, false,
handle_cold_attribute, attr_cold_hot_exclusions },
{ "hot", 0, 0, true, false, false, false,
@@ -7171,6 +7174,30 @@ handle_used_attribute (tree *pnode, tree name, tree ARG_UNUSED (args),
return NULL_TREE;
}
+/* Handle an "uninitialized" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_uninitialized_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree decl = *node;
+ if (!VAR_P (decl))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored because %qD "
+ "is not a variable", name, decl);
+ *no_add_attrs = true;
+ }
+ else if (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored because %qD "
+ "is not a local variable", name, decl);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
/* Handle a "cold" and attribute; arguments as in
struct attribute_spec.handler. */
@@ -1993,17 +1993,14 @@ gimple_add_init_for_auto_var (tree decl,
{
gcc_assert (auto_var_p (decl));
gcc_assert (init_type > AUTO_INIT_UNINITIALIZED);
- location_t loc = EXPR_LOCATION (decl);
- tree decl_size = TYPE_SIZE_UNIT (TREE_TYPE (decl));
- tree init_type_node
- = build_int_cst (integer_type_node, (int) init_type);
+ const location_t loc = DECL_SOURCE_LOCATION (decl);
+ tree decl_size = TYPE_SIZE_UNIT (TREE_TYPE (decl));
+ tree init_type_node = build_int_cst (integer_type_node, (int) init_type);
+ tree decl_name;
- tree decl_name = NULL_TREE;
if (DECL_NAME (decl))
-
decl_name = build_string_literal (DECL_NAME (decl));
-
else
{
char decl_name_anonymous[3 + (HOST_BITS_PER_INT + 2) / 3];
@@ -9848,7 +9848,6 @@ build_common_builtin_nodes (void)
ftype = build_function_type_list (void_type_node,
ptr_type_node,
ptr_type_node,
- integer_type_node,
NULL_TREE);
local_define_builtin ("__builtin_clear_padding", ftype,
BUILT_IN_CLEAR_PADDING,