From 94a073b2515f43d69404f14cd4a66eaa5301c734 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 11 Dec 2014 22:49:13 -0500 Subject: [PATCH] Remove N3639 "array of runtime length" from -std=c++14. gcc/cp/ * decl.c (compute_array_index_type): VLAs are not part of C++14. (create_array_type_for_decl, grokdeclarator): Likewise. * lambda.c (add_capture): Likewise. * pt.c (tsubst): Likewise. * rtti.c (get_tinfo_decl): Likewise. * semantics.c (finish_decltype_type): Likewise. * typeck.c (cxx_sizeof_or_alignof_type): Likewise. (cp_build_addr_expr_1): Likewise. * init.c (build_vec_init): Don't throw bad_array_length. gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_runtime_arrays if we aren't complaining about VLAs. libstdc++-v3/ * libsupc++/new (bad_array_length): Move... * bad_array_length.cc: ...here. * cxxabi.h, eh_aux_runtime.cc (__cxa_throw_bad_array_new_length): Also move to bad_array_length.cc. * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_runtime_arrays if we aren't complaining about VLAs. From-SVN: r218655 --- gcc/c-family/ChangeLog | 5 +++ gcc/c-family/c-cppbuiltin.c | 12 +++++-- gcc/cp/ChangeLog | 11 ++++++ gcc/cp/decl.c | 43 ++++-------------------- gcc/cp/init.c | 5 +-- gcc/cp/lambda.c | 2 +- gcc/cp/pt.c | 15 --------- gcc/cp/rtti.c | 9 ++--- gcc/cp/semantics.c | 10 ------ gcc/cp/tree.c | 3 +- gcc/cp/typeck.c | 23 +------------ gcc/testsuite/g++.dg/cpp0x/Wattributes1.C | 2 +- gcc/testsuite/g++.dg/cpp0x/initlist26.C | 2 +- gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C | 1 - gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C | 8 +++++ gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C | 6 ++-- gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C | 1 - gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C | 8 +++++ gcc/testsuite/g++.dg/cpp1y/feat-vla.C | 5 +++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C | 1 + gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C | 3 +- gcc/testsuite/g++.dg/cpp1y/vla1.C | 40 ---------------------- gcc/testsuite/g++.dg/cpp1y/vla10.C | 3 +- gcc/testsuite/g++.dg/cpp1y/vla11.C | 8 ----- gcc/testsuite/g++.dg/cpp1y/vla12.C | 7 ---- gcc/testsuite/g++.dg/cpp1y/vla13.C | 8 ----- gcc/testsuite/g++.dg/cpp1y/vla2.C | 3 +- gcc/testsuite/g++.dg/cpp1y/vla3.C | 29 ---------------- gcc/testsuite/g++.dg/cpp1y/vla4.C | 3 +- gcc/testsuite/g++.dg/cpp1y/vla5.C | 3 +- gcc/testsuite/g++.dg/cpp1y/vla8.C | 3 +- gcc/testsuite/g++.dg/cpp1y/vla9.C | 5 +-- gcc/testsuite/g++.dg/ext/vla11.C | 2 +- libstdc++-v3/ChangeLog | 7 ++++ libstdc++-v3/libsupc++/bad_array_length.cc | 22 ++++++++++++ libstdc++-v3/libsupc++/cxxabi.h | 3 -- libstdc++-v3/libsupc++/eh_aux_runtime.cc | 4 --- libstdc++-v3/libsupc++/new | 17 ---------- 38 files changed, 112 insertions(+), 230 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/feat-vla.C delete mode 100644 gcc/testsuite/g++.dg/cpp1y/vla1.C delete mode 100644 gcc/testsuite/g++.dg/cpp1y/vla11.C delete mode 100644 gcc/testsuite/g++.dg/cpp1y/vla12.C delete mode 100644 gcc/testsuite/g++.dg/cpp1y/vla13.C delete mode 100644 gcc/testsuite/g++.dg/cpp1y/vla3.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9cc46d4..db08d18 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2014-12-11 Jason Merrill + + * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_runtime_arrays if + we aren't complaining about VLAs. + 2014-12-06 Marek Polacek PR tree-optimization/64183 diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index c571d1b..54d3acd 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -828,6 +828,15 @@ c_cpp_builtins (cpp_reader *pfile) and were standardized for C++14. */ if (!pedantic || cxx_dialect > cxx11) cpp_define (pfile, "__cpp_binary_literals=201304"); + + /* Arrays of runtime bound were removed from C++14, but we still + support GNU VLAs. Let's define this macro to a low number + (corresponding to the initial test release of GNU C++) if we won't + complain about use of VLAs. */ + if (c_dialect_cxx () + && (pedantic ? warn_vla == 0 : warn_vla <= 0)) + cpp_define (pfile, "__cpp_runtime_arrays=198712"); + if (cxx_dialect >= cxx11) { /* Set feature test macros for C++11 */ @@ -863,9 +872,6 @@ c_cpp_builtins (cpp_reader *pfile) cpp_define (pfile, "__cpp_variable_templates=201304"); cpp_define (pfile, "__cpp_digit_separators=201309"); //cpp_define (pfile, "__cpp_sized_deallocation=201309"); - /* We'll have to see where runtime arrays wind up. - Let's put it in C++14 for now. */ - cpp_define (pfile, "__cpp_runtime_arrays=201304"); } } /* Note that we define this for C as well, so that we know if diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 52b582d..53bf2f5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,16 @@ 2014-12-11 Jason Merrill + Remove N3639 "array of runtime length" from -std=c++14. + * decl.c (compute_array_index_type): VLAs are not part of C++14. + (create_array_type_for_decl, grokdeclarator): Likewise. + * lambda.c (add_capture): Likewise. + * pt.c (tsubst): Likewise. + * rtti.c (get_tinfo_decl): Likewise. + * semantics.c (finish_decltype_type): Likewise. + * typeck.c (cxx_sizeof_or_alignof_type): Likewise. + (cp_build_addr_expr_1): Likewise. + * init.c (build_vec_init): Don't throw bad_array_length. + PR c++/64248 Revert: * parser.c (cp_parser_unqualified_id): Handle __func__ here. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9659336..efc2001 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8515,7 +8515,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) /* We don't allow VLAs at non-function scopes, or during tentative template substitution. */ || !at_function_scope_p () - || (cxx_dialect < cxx14 && !(complain & tf_error))) + || !(complain & tf_error)) { if (!(complain & tf_error)) return error_mark_node; @@ -8527,7 +8527,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) error ("size of array is not an integral constant-expression"); size = integer_one_node; } - else if (cxx_dialect < cxx14 && pedantic && warn_vla != 0) + else if (pedantic && warn_vla != 0) { if (name) pedwarn (input_location, OPT_Wvla, "ISO C++ forbids variable length array %qD", name); @@ -8585,25 +8585,12 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) stabilize_vla_size (itype); - if (cxx_dialect >= cxx14 && flag_exceptions) + if (flag_sanitize & SANITIZE_VLA + && current_function_decl != NULL_TREE + && !lookup_attribute ("no_sanitize_undefined", + DECL_ATTRIBUTES + (current_function_decl))) { - /* If the VLA bound is larger than half the address space, - or less than zero, throw std::bad_array_length. */ - tree comp = build2 (LT_EXPR, boolean_type_node, itype, - ssize_int (-1)); - comp = build3 (COND_EXPR, void_type_node, comp, - throw_bad_array_length (), void_node); - finish_expr_stmt (comp); - } - else if (flag_sanitize & SANITIZE_VLA - && current_function_decl != NULL_TREE - && !lookup_attribute ("no_sanitize_undefined", - DECL_ATTRIBUTES - (current_function_decl))) - { - /* From C++14 onwards, we throw an exception on a negative - length size of an array; see above. */ - /* We have to add 1 -- in the ubsan routine we generate LE_EXPR rather than LT_EXPR. */ tree t = fold_build2 (PLUS_EXPR, TREE_TYPE (itype), itype, @@ -8730,10 +8717,6 @@ create_array_type_for_decl (tree name, tree type, tree size) return error_mark_node; } - if (cxx_dialect >= cxx14 && array_of_runtime_bound_p (type) - && (flag_iso || warn_vla > 0)) - pedwarn (input_location, OPT_Wvla, "array of array of runtime bound"); - /* Figure out the index type for the array. */ if (size) itype = compute_array_index_type (name, size, tf_warning_or_error); @@ -9984,13 +9967,6 @@ grokdeclarator (const cp_declarator *declarator, : G_("cannot declare pointer to qualified function type %qT"), type); - if (cxx_dialect >= cxx14 && array_of_runtime_bound_p (type) - && (flag_iso || warn_vla > 0)) - pedwarn (input_location, OPT_Wvla, - declarator->kind == cdk_reference - ? G_("reference to array of runtime bound") - : G_("pointer to array of runtime bound")); - /* When the pointed-to type involves components of variable size, care must be taken to ensure that the size evaluation code is emitted early enough to dominate all the possible later uses @@ -10341,11 +10317,6 @@ grokdeclarator (const cp_declarator *declarator, type = error_mark_node; } - if (cxx_dialect >= cxx14 && array_of_runtime_bound_p (type) - && (flag_iso || warn_vla > 0)) - pedwarn (input_location, OPT_Wvla, - "typedef naming array of runtime bound"); - if (decl_context == FIELD) decl = build_lang_decl (TYPE_DECL, unqualified_id, type); else diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 19e2cdd..b987ef1 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3591,10 +3591,7 @@ 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 (); + throw_call = throw_bad_array_new_length (); length_check = build3 (COND_EXPR, void_type_node, length_check, throw_call, void_node); finish_expr_stmt (length_check); diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 01a508a..9eb9200 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -485,7 +485,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, } else if (variably_modified_type_p (type, NULL_TREE)) { - error ("capture of variable-size type %qT that is not a C++14 array " + error ("capture of variable-size type %qT that is not an N3639 array " "of runtime bound", type); if (TREE_CODE (type) == ARRAY_TYPE && variably_modified_type_p (TREE_TYPE (type), NULL_TREE)) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8e71fcb..d8a9c5b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12241,21 +12241,6 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) r = cp_build_reference_type (type, TYPE_REF_IS_RVALUE (t)); r = cp_build_qualified_type_real (r, cp_type_quals (t), complain); - if (cxx_dialect >= cxx14 - && !(TREE_CODE (t) == REFERENCE_TYPE && REFERENCE_VLA_OK (t)) - && array_of_runtime_bound_p (type) - && (flag_iso || warn_vla > 0)) - { - if (complain & tf_warning_or_error) - pedwarn - (input_location, OPT_Wvla, - code == REFERENCE_TYPE - ? G_("cannot declare reference to array of runtime bound") - : G_("cannot declare pointer to array of runtime bound")); - else - r = error_mark_node; - } - if (r != error_mark_node) /* Will this ever be needed for TYPE_..._TO values? */ layout_type (r); diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index aef71f2..2270f3d 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -396,12 +396,9 @@ get_tinfo_decl (tree type) if (variably_modified_type_p (type, /*fn=*/NULL_TREE)) { - if (array_of_runtime_bound_p (type)) - error ("typeid of array of runtime bound"); - else - error ("cannot create type information for type %qT because " - "it involves types of variable size", - type); + error ("cannot create type information for type %qT because " + "it involves types of variable size", + type); return error_mark_node; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 639702a..8a1de7e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7239,16 +7239,6 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, } } - if (cxx_dialect >= cxx14 && array_of_runtime_bound_p (type) - && (flag_iso || warn_vla > 0)) - { - if (complain & tf_warning_or_error) - pedwarn (input_location, OPT_Wvla, - "taking decltype of array of runtime bound"); - else - return error_mark_node; - } - return type; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index f8506f5..6d6abe9 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -920,7 +920,8 @@ build_array_of_n_type (tree elt, int n) return build_cplus_array_type (elt, build_index_type (size_int (n - 1))); } -/* True iff T is a C++14 array of runtime bound (VLA). */ +/* True iff T is an N3639 array of runtime bound (VLA). These were + approved for C++14 but then removed. */ bool array_of_runtime_bound_p (tree t) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index dd60d98..7b39816 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1578,16 +1578,6 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain) return value; } - if (cxx_dialect >= cxx14 && array_of_runtime_bound_p (type) - && (flag_iso || warn_vla > 0)) - { - if (complain) - pedwarn (input_location, OPT_Wvla, - "taking sizeof array of runtime bound"); - else - return error_mark_node; - } - return c_sizeof_or_alignof_type (input_location, complete_type (type), op == SIZEOF_EXPR, false, complain); @@ -5540,18 +5530,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) } if (argtype != error_mark_node) - { - if (cxx_dialect >= cxx14 && array_of_runtime_bound_p (argtype) - && (flag_iso || warn_vla > 0)) - { - if (complain & tf_warning_or_error) - pedwarn (input_location, OPT_Wvla, - "taking address of array of runtime bound"); - else - return error_mark_node; - } - argtype = build_pointer_type (argtype); - } + argtype = build_pointer_type (argtype); /* In a template, we are processing a non-dependent expression so we can just form an ADDR_EXPR with the correct type. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C index 4d3c29c..d818851 100644 --- a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C +++ b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C @@ -5,4 +5,4 @@ #include __attribute__((visibility("hidden")))void*operator new(std::size_t); // { dg-warning "visibility attribute ignored" } -// { dg-message "previous declaration" "" { target *-*-* } 128 } +// { dg-message "previous declaration" "" { target *-*-* } 111 } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist26.C b/gcc/testsuite/g++.dg/cpp0x/initlist26.C index 260ddd4..8fd267f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist26.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist26.C @@ -1,6 +1,6 @@ // PR c++/42059 // { dg-do compile { target c++11 } } -// { dg-options "" { target { ! c++14 } } } +// { dg-options "" } void foo (int i) diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C index a5b41f4..ec93189 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C @@ -1,5 +1,4 @@ // { dg-do compile { target c++11_only } } -// { dg-options "-pedantic-errors" } // C++14 features: diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C index 3d02e23..67f75a7 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C @@ -133,6 +133,14 @@ # error "__cpp_binary_literals != 201304" #endif +// GNU VLA support: + +#ifndef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#elif __cpp_runtime_arrays != 198712 +# error "__cpp_runtime_arrays != 198712" +#endif + // C++11 attributes: #ifdef __has_cpp_attribute diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C index 74748cb..d271752 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C @@ -187,12 +187,12 @@ # error "__cpp_sized_deallocation" #endif -// Array TS features: +// GNU VLA support: #ifndef __cpp_runtime_arrays # error "__cpp_runtime_arrays" -#elif __cpp_runtime_arrays != 201304 -# error "__cpp_runtime_arrays != 201304" +#elif __cpp_runtime_arrays != 198712 +# error "__cpp_runtime_arrays != 198712" #endif // C++11 attributes: diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C index e25cac3..54f42e1 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C @@ -1,5 +1,4 @@ // { dg-do compile { target c++98_only } } -// { dg-options "-ansi" } // C++11 features: diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C index dce7029..d15e7aa 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C @@ -22,3 +22,11 @@ #elif __cpp_binary_literals != 201304 # error "__cpp_binary_literals != 201304" #endif + +// GNU VLA support: + +#ifndef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#elif __cpp_runtime_arrays != 198712 +# error "__cpp_runtime_arrays != 198712" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-vla.C b/gcc/testsuite/g++.dg/cpp1y/feat-vla.C new file mode 100644 index 0000000..e313dd8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/feat-vla.C @@ -0,0 +1,5 @@ +// We shouldn't define this feature macro when we complain about VLAs. + +#ifdef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C index 90407da..4cabccb 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C @@ -1,5 +1,6 @@ // PR c++/59271 // { dg-do compile { target c++14 } } +// { dg-options "-Wno-vla" } extern "C" int printf (const char *, ...); diff --git a/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C b/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C index 7b7aa92..8f5709d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C @@ -1,4 +1,5 @@ -// { dg-do run { target c++14 } } +// { dg-do run { target c++11 } } +// { dg-options "-Wno-vla" } #include diff --git a/gcc/testsuite/g++.dg/cpp1y/vla1.C b/gcc/testsuite/g++.dg/cpp1y/vla1.C deleted file mode 100644 index cea17ef..0000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla1.C +++ /dev/null @@ -1,40 +0,0 @@ -// { dg-do compile { target c++14 } } - -#include - -void f(int n) -{ - int a[n]; - int aa[n][n]; // { dg-error "" } - &a; // { dg-error "" } - sizeof a; // { dg-error "" } - typeid(a); // { dg-error "" } - decltype(a) a2; // { dg-error "" } - typedef int at[n]; // { dg-error "" } - int (*p)[n]; // { dg-error "" } - int (&r)[n] = a; // { dg-error "" } - struct A - { - int a[n]; // { dg-error "" } - }; -} - -template -void g(int n) -{ - int a[n]; - int aa[n][n]; // { dg-error "" } - &a; // { dg-error "" } - sizeof a; // { dg-error "" } - typeid(a); // { dg-error "" } - decltype(a) a2; // { dg-error "" } - typedef int at[n]; // { dg-error "" } - int (*p)[n]; // { dg-error "" } - int (&r)[n] = a; // { dg-error "" } - struct A - { - int a[n]; // { dg-error "" } - }; -} - -template void g(int); diff --git a/gcc/testsuite/g++.dg/cpp1y/vla10.C b/gcc/testsuite/g++.dg/cpp1y/vla10.C index 38fb145..f81ab9b 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla10.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla10.C @@ -1,5 +1,6 @@ // PR c++/57402 -// { dg-do compile { target c++14 } } +// { dg-do run } +// { dg-options "" } int i = 2; diff --git a/gcc/testsuite/g++.dg/cpp1y/vla11.C b/gcc/testsuite/g++.dg/cpp1y/vla11.C deleted file mode 100644 index ca22635..0000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla11.C +++ /dev/null @@ -1,8 +0,0 @@ -// PR c++/60251 -// { dg-do compile { target c++14 } } - -void foo(int n) -{ - int x[n]; - [&x]() { decltype(x) y; }; // { dg-error "decltype of array of runtime bound" } -} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla12.C b/gcc/testsuite/g++.dg/cpp1y/vla12.C deleted file mode 100644 index 7fc9987..0000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla12.C +++ /dev/null @@ -1,7 +0,0 @@ -// PR c++/60250 -// { dg-do compile { target c++14 } } - -template void foo() -{ - typedef int T[ ([](){ return 1; }()) ]; // { dg-error "runtime bound" } -} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla13.C b/gcc/testsuite/g++.dg/cpp1y/vla13.C deleted file mode 100644 index f5dab26..0000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla13.C +++ /dev/null @@ -1,8 +0,0 @@ -// PR c++/60227 -// { dg-do compile { target c++14 } } - -void foo(int n) -{ - int a[n]; - int (&r)[n] = {}; // { dg-error "" } -} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla2.C b/gcc/testsuite/g++.dg/cpp1y/vla2.C index c9a452d..07c3008 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla2.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla2.C @@ -1,5 +1,6 @@ // N3639 allows initialization and capture of VLAs -// { dg-do run { target c++14 } } +// { dg-do run { target c++11 } } +// { dg-options "-Wno-vla" } void f(int n) { diff --git a/gcc/testsuite/g++.dg/cpp1y/vla3.C b/gcc/testsuite/g++.dg/cpp1y/vla3.C deleted file mode 100644 index a3d8adb..0000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla3.C +++ /dev/null @@ -1,29 +0,0 @@ -// Test for throwing bad_array_length on invalid array length -// { dg-do run { target c++14 } } - -#include - -int f(int i) -{ - int ar[i]{1,2,3,4}; - return ar[i-1]; -} - -void g(int i) -{ - int ar[i]; - ar[0] = 42; -} - -int main() -{ - int ok = 0; - f(4); // OK - try { f(3); } // too small - catch (std::bad_array_length) { ++ok; } - try { g(-24); } // negative - catch (std::bad_array_length) { ++ok; } - - if (ok != 2) - __builtin_abort (); -} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla4.C b/gcc/testsuite/g++.dg/cpp1y/vla4.C index 29df98c..74bf66a 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla4.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla4.C @@ -1,5 +1,6 @@ // Test for range-based for with VLAs. -// { dg-do run { target c++14 } } +// { dg-do run { target c++11 } } +// { dg-options "-Wno-vla" } #include diff --git a/gcc/testsuite/g++.dg/cpp1y/vla5.C b/gcc/testsuite/g++.dg/cpp1y/vla5.C index cc67a75..6bfbece 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla5.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla5.C @@ -1,5 +1,6 @@ // PR c++/55149 -// { dg-do compile { target c++14 } } +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-vla" } void test(int n) { int r[n]; diff --git a/gcc/testsuite/g++.dg/cpp1y/vla8.C b/gcc/testsuite/g++.dg/cpp1y/vla8.C index 2c821e1..68cafe5 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla8.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla8.C @@ -1,5 +1,6 @@ // PR c++/55149 -// { dg-do compile { target c++14 } } +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-vla" } template struct SA diff --git a/gcc/testsuite/g++.dg/cpp1y/vla9.C b/gcc/testsuite/g++.dg/cpp1y/vla9.C index eb58e1a..939de30 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla9.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla9.C @@ -1,5 +1,6 @@ // PR c++/57408 -// { dg-do compile { target c++14 } } +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-vla" } template struct Impl @@ -19,7 +20,7 @@ extern "C" int printf(const char*, ...); int main(){ int y = 2; - float fa[2][y]; // { dg-error "array of array of runtime bound" } + float fa[2][y]; fa[0][0]=0.8; fa[0][1]=1.8; auto fx=[&](){ diff --git a/gcc/testsuite/g++.dg/ext/vla11.C b/gcc/testsuite/g++.dg/ext/vla11.C index c283a18..e733f48 100644 --- a/gcc/testsuite/g++.dg/ext/vla11.C +++ b/gcc/testsuite/g++.dg/ext/vla11.C @@ -1,6 +1,6 @@ // Test that auto works with VLAs. // { dg-do compile { target c++11 } } -// { dg-options "" { target { ! c++14 } } } +// { dg-options "-Wno-vla" } void bar(int n) { diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7039613..0c125ec 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2014-12-11 Jason Merrill + + * libsupc++/new (bad_array_length): Move... + * bad_array_length.cc: ...here. + * cxxabi.h, eh_aux_runtime.cc (__cxa_throw_bad_array_new_length): Also + move to bad_array_length.cc. + 2014-12-11 Jonathan Wakely * testsuite/30_threads/condition_variable/members/3.cc: Only use diff --git a/libstdc++-v3/libsupc++/bad_array_length.cc b/libstdc++-v3/libsupc++/bad_array_length.cc index c5370c3..0230a38 100644 --- a/libstdc++-v3/libsupc++/bad_array_length.cc +++ b/libstdc++-v3/libsupc++/bad_array_length.cc @@ -25,6 +25,20 @@ namespace std { +// From N3639. This was voted in and then back out of C++14, and is now +// just here for backward link compatibility with code built with 4.9. +class bad_array_length : public bad_alloc +{ +public: + bad_array_length() throw() { }; + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_array_length() throw(); + + // See comment in eh_exception.cc. + virtual const char* what() const throw(); +}; bad_array_length::~bad_array_length() _GLIBCXX_USE_NOEXCEPT { } @@ -33,3 +47,11 @@ bad_array_length::what() const _GLIBCXX_USE_NOEXCEPT { return "std::bad_array_length"; } } // namespace std + +namespace __cxxabiv1 { + +extern "C" void +__cxa_throw_bad_array_length () +{ _GLIBCXX_THROW_OR_ABORT(std::bad_array_length()); } + +} // namespace __cxxabiv1 diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h index 4d9458c..36048f3 100644 --- a/libstdc++-v3/libsupc++/cxxabi.h +++ b/libstdc++-v3/libsupc++/cxxabi.h @@ -154,9 +154,6 @@ namespace __cxxabiv1 void __cxa_throw_bad_array_new_length() __attribute__((__noreturn__)); - void - __cxa_throw_bad_array_length() __attribute__((__noreturn__)); - /** * @brief Demangling routine. * ABI-mandated entry point in the C++ runtime library for demangling. diff --git a/libstdc++-v3/libsupc++/eh_aux_runtime.cc b/libstdc++-v3/libsupc++/eh_aux_runtime.cc index 3b4037a..1846aa2 100644 --- a/libstdc++-v3/libsupc++/eh_aux_runtime.cc +++ b/libstdc++-v3/libsupc++/eh_aux_runtime.cc @@ -40,7 +40,3 @@ __cxxabiv1::__cxa_bad_typeid () extern "C" void __cxxabiv1::__cxa_throw_bad_array_new_length () { _GLIBCXX_THROW_OR_ABORT(std::bad_array_new_length()); } - -extern "C" void -__cxxabiv1::__cxa_throw_bad_array_length () -{ _GLIBCXX_THROW_OR_ABORT(std::bad_array_length()); } diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index a65a0b8..76eddfc 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -79,23 +79,6 @@ namespace std }; #endif - // We throw this exception for GNU VLAs of negative length in all C++ - // dialects, so declare it if we aren't in strict conformance mode. -#if __cplusplus > 201103L || !defined(__STRICT_ANSI__) - class bad_array_length : public bad_alloc - { - public: - bad_array_length() throw() { }; - - // This declaration is not useless: - // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 - virtual ~bad_array_length() throw(); - - // See comment in eh_exception.cc. - virtual const char* what() const throw(); - }; -#endif - struct nothrow_t { }; extern const nothrow_t nothrow; -- 2.7.4