diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-09 16:43:36 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-09 16:43:36 +0000 |
commit | b749017fafed446f28d44b6fd3345a5fd39faaf1 (patch) | |
tree | 0ff2545c076f920080c2715f42b04536c9c75c62 /gcc/cp/init.c | |
parent | 4fa680c37ccfb7be51a72e981485df6deefc783c (diff) | |
download | ppe42-gcc-b749017fafed446f28d44b6fd3345a5fd39faaf1.tar.gz ppe42-gcc-b749017fafed446f28d44b6fd3345a5fd39faaf1.zip |
N3639 C++1y VLA support
gcc/
* gimplify.c (gimplify_vla_decl): Don't touch an existing
DECL_VALUE_EXPR.
gcc/cp/
* decl.c (compute_array_index_type): Allow VLAs in C++1y mode.
(check_array_initializer): Allow VLA init.
(reshape_init_array_1): Adjust.
(cp_finish_decl): Check for invalid VLA length.
* typeck2.c (process_init_constructor_array): Adjust.
(store_init_value): Use build_vec_init for VLAs.
* semantics.c (add_capture): Capture VLA as ptr+len.
(vla_capture_type): New.
(build_capture_proxy): Rebuild the VLA.
* typeck.c (build_simple_component_ref): Split out from...
(build_ptrmemfunc_access_expr): ...here.
* tree.c (array_of_runtime_bound_p): New.
* init.c (throw_bad_array_length): New.
(build_vec_init): Use it.
* parser.c (cp_convert_range_for): When iterating over a VLA,
use it directly rather than bind a reference.
* cp-tree.h: Declare new functions.
libstdc++-v3/
* libsupc++/new: Add std::bad_array_length.
* libsupc++/bad_array_length.cc: New.
* libsupc++/eh_aux_runtime.cc: Add __cxa_bad_array_length.
* libsupc++/Makefile.in: Build them.
* config/abi/pre/gnu.ver: Add new symbols.
* config/abi/pre/gnu-versioned-namespace.ver: Add new symbols.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198745 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 765c47192cf..d687a8428ce 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2185,6 +2185,20 @@ throw_bad_array_new_length (void) return build_cxx_call (fn, 0, NULL, tf_warning_or_error); } +/* Call __cxa_bad_array_length to indicate that there were too many + initializers. */ + +tree +throw_bad_array_length (void) +{ + tree fn = get_identifier ("__cxa_throw_bad_array_length"); + if (!get_global_value_if_present (fn, &fn)) + fn = push_throw_library_fn (fn, build_function_type_list (void_type_node, + NULL_TREE)); + + return build_cxx_call (fn, 0, NULL, tf_warning_or_error); +} + /* Generate code for a new-expression, including calling the "operator new" function, initializing the object, and, if an exception occurs during construction, cleaning up. The arguments are as for @@ -3350,6 +3364,10 @@ build_vec_init (tree base, tree maxindex, tree init, store_constructor will handle the semantics for us. */ stmt_expr = build2 (INIT_EXPR, atype, base, init); + if (length_check) + stmt_expr = build3 (COND_EXPR, atype, length_check, + throw_bad_array_length (), + stmt_expr); return stmt_expr; } @@ -3467,6 +3485,9 @@ build_vec_init (tree base, tree maxindex, tree init, if (length_check) { tree throw_call; + if (array_of_runtime_bound_p (atype)) + throw_call = throw_bad_array_length (); + else throw_call = throw_bad_array_new_length (); length_check = build3 (COND_EXPR, void_type_node, length_check, throw_call, void_zero_node); |