aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexander Ivchenko <alexander.ivchenko@intel.com>2013-11-23 16:28:42 +0000
committerJason Merrill <jason@gcc.gnu.org>2013-11-23 11:28:42 -0500
commitf391b44b199e27712c15ea880f54f41cd11f34e3 (patch)
treedd027478c82250512192ee3a1ebe30071d6d293b /gcc
parent4417887978f491e497451598d0b596af3fe62b8c (diff)
downloadgcc-f391b44b199e27712c15ea880f54f41cd11f34e3.zip
gcc-f391b44b199e27712c15ea880f54f41cd11f34e3.tar.gz
gcc-f391b44b199e27712c15ea880f54f41cd11f34e3.tar.bz2
re PR c++/58525 (__cxa_throw_bad_array_new_length is generated with -fno-exceptions)
PR c++/58525 * call.c (build_operator_new_call): Add flag_exceptions check. * decl.c (compute_array_index_type): Ditto. * init.c (build_new_1): Ditto. (build_vec_init): Ditto. From-SVN: r205310
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/call.c2
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/cp/init.c5
4 files changed, 13 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ee0674c..05aa444 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2013-11-23 Alexander Ivchenko <alexander.ivchenko@intel.com>
+
+ PR c++/58525
+ * call.c (build_operator_new_call): Add flag_exceptions check.
+ * decl.c (compute_array_index_type): Ditto.
+ * init.c (build_new_1): Ditto.
+ (build_vec_init): Ditto.
+
2013-11-22 Jakub Jelinek <jakub@redhat.com>
* cp-gimplify.c: Include target.h and c-family/c-ubsan.h.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 935e011..6a4386e 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3956,7 +3956,7 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args,
if (size_check != NULL_TREE)
{
tree errval = TYPE_MAX_VALUE (sizetype);
- if (cxx_dialect >= cxx11)
+ if (cxx_dialect >= cxx11 && flag_exceptions)
errval = throw_bad_array_new_length ();
*size = fold_build3 (COND_EXPR, sizetype, size_check,
original_size, errval);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 40a9a8c..889c203 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8393,7 +8393,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain)
stabilize_vla_size (itype);
- if (cxx_dialect >= cxx1y)
+ if (cxx_dialect >= cxx1y && flag_exceptions)
{
/* If the VLA bound is larger than half the address space,
or less than zero, throw std::bad_array_length. */
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index d67a389..dc40989 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2528,7 +2528,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,
@@ -3398,7 +3398,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));