]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/cp/typeck2.c
Merge in trunk.
[thirdparty/gcc.git] / gcc / cp / typeck2.c
index 3fc046619bc2d1eb64716da9ce203a635595343b..cb5f715f6506157ad6c9fed3eff3754841a30d95 100644 (file)
@@ -641,12 +641,13 @@ split_nonconstant_init_1 (tree dest, tree init)
              code = build_stmt (input_location, EXPR_STMT, code);
              code = maybe_cleanup_point_expr_void (code);
              add_stmt (code);
-             if (!TYPE_HAS_TRIVIAL_DESTRUCTOR (inner_type))
+             if (type_build_dtor_call (inner_type))
                {
                  code = (build_special_member_call
                          (sub, complete_dtor_identifier, NULL, inner_type,
                           LOOKUP_NORMAL, tf_warning_or_error));
-                 finish_eh_cleanup (code);
+                 if (!TYPE_HAS_TRIVIAL_DESTRUCTOR (inner_type))
+                   finish_eh_cleanup (code);
                }
 
              num_split_elts++;
@@ -775,7 +776,6 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
     {
       bool const_init;
       value = fold_non_dependent_expr (value);
-      value = maybe_constant_init (value);
       if (DECL_DECLARED_CONSTEXPR_P (decl)
          || DECL_IN_AGGR_P (decl))
        {
@@ -786,6 +786,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
          else
            value = cxx_constant_value (value);
        }
+      value = maybe_constant_init (value);
       const_init = (reduced_constant_expression_p (value)
                    || error_operand_p (value));
       DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = const_init;
@@ -834,7 +835,8 @@ check_narrowing (tree type, tree init)
       && TREE_CODE (type) == COMPLEX_TYPE)
     {
       tree elttype = TREE_TYPE (type);
-      check_narrowing (elttype, CONSTRUCTOR_ELT (init, 0)->value);
+      if (CONSTRUCTOR_NELTS (init) > 0)
+        check_narrowing (elttype, CONSTRUCTOR_ELT (init, 0)->value);
       if (CONSTRUCTOR_NELTS (init) > 1)
        check_narrowing (elttype, CONSTRUCTOR_ELT (init, 1)->value);
       return;