]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (check_initializer): Set DECL_NONTRIVIALLY_INITIALIZED_P for a constructor...
authorJason Merrill <jason@redhat.com>
Mon, 1 Oct 2012 23:57:18 +0000 (19:57 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 1 Oct 2012 23:57:18 +0000 (19:57 -0400)
* decl.c (check_initializer): Set DECL_NONTRIVIALLY_INITIALIZED_P
for a constructor call.
(decl_jump_unsafe): So don't bother checking
type_has_nontrivial_default_init.
* call.c (set_up_extended_ref_temp): Set
DECL_NONTRIVIALLY_INITIALIZED_P.

From-SVN: r191948

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/decl.c

index 487841a365ea83b095886fb96c0bd3dc76639726..f868739be6ef1643e474d93f6e78e1d3ba9426a8 100644 (file)
@@ -1,5 +1,12 @@
 2012-10-01  Jason Merrill  <jason@redhat.com>
 
+       * decl.c (check_initializer): Set DECL_NONTRIVIALLY_INITIALIZED_P
+       for a constructor call.
+       (decl_jump_unsafe): So don't bother checking
+       type_has_nontrivial_default_init.
+       * call.c (set_up_extended_ref_temp): Set
+       DECL_NONTRIVIALLY_INITIALIZED_P.
+
        * cp-tree.h (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK): New.
        (DECL_FRIEND_P, DECL_ANTICIPATED): Use it.
        (TYPE_FUNCTION_OR_TEMPLATE_DECL_P): New.
index 6f7e34669ce86e830d77334491aacfcc2d97b994..d0492d8deef007a37c013155175c0adbcd65331e 100644 (file)
@@ -8792,6 +8792,9 @@ set_up_extended_ref_temp (tree decl, tree expr, VEC(tree,gc) **cleanups,
   TARGET_EXPR_INITIAL (expr)
     = extend_ref_init_temps (decl, TARGET_EXPR_INITIAL (expr), cleanups);
 
+  /* Any reference temp has a non-trivial initializer.  */
+  DECL_NONTRIVIALLY_INITIALIZED_P (var) = true;
+
   /* If the initializer is constant, put it in DECL_INITIAL so we get
      static initialization and use in constant expressions.  */
   init = maybe_constant_init (expr);
index e4f3761802e0baac464263554730ede75b615fcc..bfe7ad70e0c0fcae38f591deb7e3289b2d5ea007 100644 (file)
@@ -2271,12 +2271,13 @@ struct GTY((variable_size)) lang_decl {
 
 /* Nonzero for a VAR_DECL means that the variable's initialization (if
    any) has been processed.  (In general, DECL_INITIALIZED_P is
-   !DECL_EXTERN, but static data members may be initialized even if
+   !DECL_EXTERNAL, but static data members may be initialized even if
    not defined.)  */
 #define DECL_INITIALIZED_P(NODE) \
    (TREE_LANG_FLAG_1 (VAR_DECL_CHECK (NODE)))
 
-/* Nonzero for a VAR_DECL iff an explicit initializer was provided.  */
+/* Nonzero for a VAR_DECL iff an explicit initializer was provided
+   or a non-trivial constructor is called.  */
 #define DECL_NONTRIVIALLY_INITIALIZED_P(NODE)  \
    (TREE_LANG_FLAG_3 (VAR_DECL_CHECK (NODE)))
 
index d4c78e15bc100268e405cf7f5ad173b80b926f12..d0933efc8dd7e80b0fd9b063ba932d85460e047c 100644 (file)
@@ -2679,8 +2679,7 @@ decl_jump_unsafe (tree decl)
 
   type = strip_array_types (type);
 
-  if (type_has_nontrivial_default_init (TREE_TYPE (decl))
-      || DECL_NONTRIVIALLY_INITIALIZED_P (decl))
+  if (DECL_NONTRIVIALLY_INITIALIZED_P (decl))
     return 2;
 
   if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
@@ -5581,6 +5580,11 @@ check_initializer (tree decl, tree init, int flags, VEC(tree,gc) **cleanups)
        {
          init_code = build_aggr_init_full_exprs (decl, init, flags);
 
+         /* A constructor call is a non-trivial initializer even if
+            it isn't explicitly written.  */
+         if (TREE_SIDE_EFFECTS (init_code))
+           DECL_NONTRIVIALLY_INITIALIZED_P (decl) = true;
+
          /* If this is a constexpr initializer, expand_default_init will
             have returned an INIT_EXPR rather than a CALL_EXPR.  In that
             case, pull the initializer back out and pass it down into