aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/cp/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/cp/decl.c')
-rw-r--r--gcc-4.9/gcc/cp/decl.c63
1 files changed, 36 insertions, 27 deletions
diff --git a/gcc-4.9/gcc/cp/decl.c b/gcc-4.9/gcc/cp/decl.c
index df4813deb..50faaebc6 100644
--- a/gcc-4.9/gcc/cp/decl.c
+++ b/gcc-4.9/gcc/cp/decl.c
@@ -632,8 +632,7 @@ poplevel (int keep, int reverse, int functionbody)
push_local_binding where the list of decls returned by
getdecls is built. */
decl = TREE_CODE (d) == TREE_LIST ? TREE_VALUE (d) : d;
- // See through references for improved -Wunused-variable (PR 38958).
- tree type = non_reference (TREE_TYPE (decl));
+ tree type = TREE_TYPE (decl);
if (VAR_P (decl)
&& (! TREE_USED (decl) || !DECL_READ_P (decl))
&& ! DECL_IN_SYSTEM_HEADER (decl)
@@ -4822,11 +4821,26 @@ grok_reference_init (tree decl, tree type, tree init, int flags)
init = build_x_compound_expr_from_list (init, ELK_INIT,
tf_warning_or_error);
- if (TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE
+ tree ttype = TREE_TYPE (type);
+ if (TREE_CODE (ttype) != ARRAY_TYPE
&& TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE)
/* Note: default conversion is only called in very special cases. */
init = decay_conversion (init, tf_warning_or_error);
+ /* check_initializer handles this for non-reference variables, but for
+ references we need to do it here or the initializer will get the
+ incomplete array type and confuse later calls to
+ cp_complete_array_type. */
+ if (TREE_CODE (ttype) == ARRAY_TYPE
+ && TYPE_DOMAIN (ttype) == NULL_TREE
+ && (BRACE_ENCLOSED_INITIALIZER_P (init)
+ || TREE_CODE (init) == STRING_CST))
+ {
+ cp_complete_array_type (&ttype, init, false);
+ if (ttype != TREE_TYPE (type))
+ type = cp_build_reference_type (ttype, TYPE_REF_IS_RVALUE (type));
+ }
+
/* Convert INIT to the reference type TYPE. This may involve the
creation of a temporary, whose lifetime must be the same as that
of the reference. If so, a DECL_EXPR for the temporary will be
@@ -7021,7 +7035,7 @@ expand_static_init (tree decl, tree init)
looks like:
static <type> guard;
- if (!guard.first_byte) {
+ if (!__atomic_load (guard.first_byte)) {
if (__cxa_guard_acquire (&guard)) {
bool flag = false;
try {
@@ -7051,16 +7065,11 @@ expand_static_init (tree decl, tree init)
/* Create the guard variable. */
guard = get_guard (decl);
- /* This optimization isn't safe on targets with relaxed memory
- consistency. On such targets we force synchronization in
- __cxa_guard_acquire. */
- if (!targetm.relaxed_ordering || !thread_guard)
- {
- /* Begin the conditional initialization. */
- if_stmt = begin_if_stmt ();
- finish_if_stmt_cond (get_guard_cond (guard), if_stmt);
- then_clause = begin_compound_stmt (BCS_NO_SCOPE);
- }
+ /* Begin the conditional initialization. */
+ if_stmt = begin_if_stmt ();
+
+ finish_if_stmt_cond (get_guard_cond (guard, thread_guard), if_stmt);
+ then_clause = begin_compound_stmt (BCS_NO_SCOPE);
if (thread_guard)
{
@@ -7129,12 +7138,9 @@ expand_static_init (tree decl, tree init)
finish_if_stmt (inner_if_stmt);
}
- if (!targetm.relaxed_ordering || !thread_guard)
- {
- finish_compound_stmt (then_clause);
- finish_then_clause (if_stmt);
- finish_if_stmt (if_stmt);
- }
+ finish_compound_stmt (then_clause);
+ finish_then_clause (if_stmt);
+ finish_if_stmt (if_stmt);
}
else if (DECL_THREAD_LOCAL_P (decl))
tls_aggregates = tree_cons (init, decl, tls_aggregates);
@@ -13685,13 +13691,16 @@ begin_destructor_body (void)
initialize_vtbl_ptrs (current_class_ptr);
finish_compound_stmt (compound_stmt);
- /* Insert a cleanup to let the back end know that the object is dead
- when we exit the destructor, either normally or via exception. */
- tree clobber = build_constructor (current_class_type, NULL);
- TREE_THIS_VOLATILE (clobber) = true;
- tree exprstmt = build2 (MODIFY_EXPR, current_class_type,
- current_class_ref, clobber);
- finish_decl_cleanup (NULL_TREE, exprstmt);
+ if (flag_lifetime_dse)
+ {
+ /* Insert a cleanup to let the back end know that the object is dead
+ when we exit the destructor, either normally or via exception. */
+ tree clobber = build_constructor (current_class_type, NULL);
+ TREE_THIS_VOLATILE (clobber) = true;
+ tree exprstmt = build2 (MODIFY_EXPR, current_class_type,
+ current_class_ref, clobber);
+ finish_decl_cleanup (NULL_TREE, exprstmt);
+ }
/* And insert cleanups for our bases and members so that they
will be properly destroyed if we throw. */