aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/call.cc15
-rw-r--r--gcc/cp/tree.cc9
2 files changed, 20 insertions, 4 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 2736f55..5d504e5 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -4274,7 +4274,9 @@ maybe_init_list_as_array (tree elttype, tree init)
init_elttype = cp_build_qualified_type (init_elttype, TYPE_QUAL_CONST);
tree arr = build_array_of_n_type (init_elttype, CONSTRUCTOR_NELTS (init));
- return finish_compound_literal (arr, init, tf_none);
+ arr = finish_compound_literal (arr, init, tf_none);
+ DECL_MERGEABLE (TARGET_EXPR_SLOT (arr)) = true;
+ return arr;
}
/* If we were going to call e.g. vector(initializer_list<string>) starting
@@ -8558,6 +8560,8 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
(elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST);
array = build_array_of_n_type (elttype, len);
array = finish_compound_literal (array, new_ctor, complain);
+ /* This is dubious now, should be blessed by P2752. */
+ DECL_MERGEABLE (TARGET_EXPR_SLOT (array)) = true;
/* Take the address explicitly rather than via decay_conversion
to avoid the error about taking the address of a temporary. */
array = cp_build_addr_expr (array, complain);
@@ -13571,8 +13575,13 @@ set_up_extended_ref_temp (tree decl, tree expr, vec<tree, va_gc> **cleanups,
VAR. */
if (TREE_CODE (expr) != TARGET_EXPR)
expr = get_target_expr (expr);
- else if (TREE_ADDRESSABLE (expr))
- TREE_ADDRESSABLE (var) = 1;
+ else
+ {
+ if (TREE_ADDRESSABLE (expr))
+ TREE_ADDRESSABLE (var) = 1;
+ if (DECL_MERGEABLE (TARGET_EXPR_SLOT (expr)))
+ DECL_MERGEABLE (var) = true;
+ }
if (TREE_CODE (decl) == FIELD_DECL
&& extra_warnings && !warning_suppressed_p (decl))
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 19dfb3e..4d5e3f5 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -5045,7 +5045,14 @@ handle_no_unique_addr_attribute (tree* node,
int /*flags*/,
bool* no_add_attrs)
{
- if (TREE_CODE (*node) != FIELD_DECL)
+ if (TREE_CODE (*node) == VAR_DECL)
+ {
+ DECL_MERGEABLE (*node) = true;
+ if (pedantic)
+ warning (OPT_Wattributes, "%qE attribute can only be applied to "
+ "non-static data members", name);
+ }
+ else if (TREE_CODE (*node) != FIELD_DECL)
{
warning (OPT_Wattributes, "%qE attribute can only be applied to "
"non-static data members", name);