]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/cp/init.c
Merge with trunk.
[thirdparty/gcc.git] / gcc / cp / init.c
index 7b6f4e28e193b9aa8bfb33cc09d3698b046f819e..86b690349d24500252212fde995df1c04a487f21 100644 (file)
@@ -30,7 +30,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "cp-tree.h"
 #include "flags.h"
 #include "target.h"
-#include "gimple.h"
 #include "gimplify.h"
 #include "wide-int.h"
 
@@ -1509,7 +1508,8 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
       TREE_READONLY (exp) = was_const;
       TREE_THIS_VOLATILE (exp) = was_volatile;
       TREE_TYPE (exp) = type;
-      if (init)
+      /* Restore the type of init unless it was used directly.  */
+      if (init && TREE_CODE (stmt_expr) != INIT_EXPR)
        TREE_TYPE (init) = itype;
       return stmt_expr;
     }
@@ -2319,7 +2319,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
        {
          if (complain & tf_error)
            {
-             error_at (EXPR_LOC_OR_HERE (inner_nelts),
+             error_at (EXPR_LOC_OR_LOC (inner_nelts, input_location),
                        "array size in operator new must be constant");
              cxx_constant_value(inner_nelts);
            }
@@ -2347,7 +2347,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
       && !TREE_CONSTANT (maybe_constant_value (outer_nelts)))
     {
       if (complain & tf_warning_or_error)
-       pedwarn(EXPR_LOC_OR_HERE (outer_nelts), OPT_Wvla,
+       pedwarn(EXPR_LOC_OR_LOC (outer_nelts, input_location), OPT_Wvla,
                "ISO C++ does not support variable-length array types");
       else
        return error_mark_node;
@@ -2527,7 +2527,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
            }
          /* Perform the overflow check.  */
          tree errval = TYPE_MAX_VALUE (sizetype);
-         if (cxx_dialect >= cxx11)
+         if (cxx_dialect >= cxx11 && flag_exceptions)
            errval = throw_bad_array_new_length ();
          if (outer_nelts_check != NULL_TREE)
             size = fold_build3 (COND_EXPR, sizetype, outer_nelts_check,
@@ -3397,7 +3397,8 @@ build_vec_init (tree base, tree maxindex, tree init,
      is big enough for all the initializers.  */
   if (init && TREE_CODE (init) == CONSTRUCTOR
       && CONSTRUCTOR_NELTS (init) > 0
-      && !TREE_CONSTANT (maxindex))
+      && !TREE_CONSTANT (maxindex)
+      && flag_exceptions)
     length_check = fold_build2 (LT_EXPR, boolean_type_node, maxindex,
                                size_int (CONSTRUCTOR_NELTS (init) - 1));
 
@@ -3419,6 +3420,8 @@ build_vec_init (tree base, tree maxindex, tree init,
         brace-enclosed initializers.  In this case, digest_init and
         store_constructor will handle the semantics for us.  */
 
+      if (BRACE_ENCLOSED_INITIALIZER_P (init))
+       init = digest_init (atype, init, complain);
       stmt_expr = build2 (INIT_EXPR, atype, base, init);
       if (length_check)
        stmt_expr = build3 (COND_EXPR, atype, length_check,