From: Jakub Jelinek Date: Wed, 21 Sep 2016 15:13:46 +0000 (+0200) Subject: re PR c++/77651 (c++ -Wno-aligned-new ICEs) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2e1c20b1442e4ad7f008739d4ba08f5410032d4f;p=gcc.git re PR c++/77651 (c++ -Wno-aligned-new ICEs) PR c++/77651 c-family/ * c.opt (Waligned-new=): Add RejectNegative. (faligned-new=): Likewise. Spelling fix - change aligned_new_threshhold to aligned_new_threshold. * c-cppbuiltin.c (c_cpp_builtins): Change aligned_new_threshhold to aligned_new_threshold. cp/ * init.c (build_new_1): Don't suggest to use -faligned-new if aligned_new_threshold is non-zero. (type_has_new_extended_alignment): Change aligned_new_threshhold to aligned_new_threshold. * call.c (second_parm_is_size_t, aligned_allocation_fn_p, aligned_deallocation_fn_p, build_op_delete_call): Likewise. * decl.c (cxx_init_decl_processing): Likewise. testsuite/ * g++.dg/cpp1z/aligned-new6.C: New test. From-SVN: r240317 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index da3fdd43aad..e10245061aa 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2016-09-21 Jakub Jelinek + + PR c++/77651 + * c.opt (Waligned-new=): Add RejectNegative. + (faligned-new=): Likewise. Spelling fix - change + aligned_new_threshhold to aligned_new_threshold. + * c-cppbuiltin.c (c_cpp_builtins): Change aligned_new_threshhold + to aligned_new_threshold. + 2016-09-20 Martin Sebor PR middle-end/49905 diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index bb30829c987..6f438117966 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -944,11 +944,11 @@ c_cpp_builtins (cpp_reader *pfile) cpp_define (pfile, "__cpp_transactional_memory=210500"); if (flag_sized_deallocation) cpp_define (pfile, "__cpp_sized_deallocation=201309"); - if (aligned_new_threshhold) + if (aligned_new_threshold) { cpp_define (pfile, "__cpp_aligned_new=201606"); cpp_define_formatted (pfile, "__STDCPP_DEFAULT_NEW_ALIGNMENT__=%d", - aligned_new_threshhold); + aligned_new_threshold); } } /* Note that we define this for C as well, so that we know if diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index d01052d44e0..3a02dbb4844 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -288,7 +288,7 @@ C++ ObjC++ Alias(Waligned-new=,global,none) Warn about 'new' of type with extended alignment without -faligned-new. Waligned-new= -C++ ObjC++ Var(warn_aligned_new) Enum(warn_aligned_new_level) Joined Warning LangEnabledBy(C++ ObjC++,Wall,1,0) +C++ ObjC++ Var(warn_aligned_new) Enum(warn_aligned_new_level) Joined RejectNegative Warning LangEnabledBy(C++ ObjC++,Wall,1,0) -Waligned-new=all Warn even if 'new' uses a class member allocation function. Wall @@ -1071,7 +1071,7 @@ C++ ObjC++ Alias(faligned-new=,1,0) Support C++17 allocation of over-aligned types. faligned-new= -C++ ObjC++ Joined Var(aligned_new_threshhold) UInteger Init(-1) +C++ ObjC++ Joined RejectNegative Var(aligned_new_threshold) UInteger Init(-1) -faligned-new= Use C++17 over-aligned type allocation for alignments greater than N. fall-virtual diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0babd50d2bd..6bafde59893 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2016-09-21 Jakub Jelinek + + PR c++/77651 + * init.c (build_new_1): Don't suggest to use -faligned-new if + aligned_new_threshold is non-zero. + (type_has_new_extended_alignment): Change aligned_new_threshhold + to aligned_new_threshold. + * call.c (second_parm_is_size_t, aligned_allocation_fn_p, + aligned_deallocation_fn_p, build_op_delete_call): Likewise. + * decl.c (cxx_init_decl_processing): Likewise. + 2016-09-20 Jakub Jelinek PR c++/77626 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 393aab91bee..b6f65d2fe05 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5965,7 +5965,7 @@ second_parm_is_size_t (tree fn) t = TREE_CHAIN (t); if (t == void_list_node) return true; - if (aligned_new_threshhold && t + if (aligned_new_threshold && t && same_type_p (TREE_VALUE (t), align_type_node) && TREE_CHAIN (t) == void_list_node) return true; @@ -5978,7 +5978,7 @@ second_parm_is_size_t (tree fn) bool aligned_allocation_fn_p (tree t) { - if (!aligned_new_threshhold) + if (!aligned_new_threshold) return false; tree a = FUNCTION_ARG_CHAIN (t); @@ -5992,7 +5992,7 @@ aligned_allocation_fn_p (tree t) static bool aligned_deallocation_fn_p (tree t) { - if (!aligned_new_threshhold) + if (!aligned_new_threshold) return false; /* A template instance is never a usual deallocation function, @@ -6202,7 +6202,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, selection process terminates. If more than one preferred function is found, all non-preferred functions are eliminated from further consideration. */ - if (aligned_new_threshhold) + if (aligned_new_threshold) { bool want_align = type_has_new_extended_alignment (type); bool fn_align = aligned_deallocation_fn_p (fn); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2f444656842..921f8d5ffb5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4132,16 +4132,16 @@ cxx_init_decl_processing (void) /* Now, C++. */ current_lang_name = lang_name_cplusplus; - if (aligned_new_threshhold > 1 - && !pow2p_hwi (aligned_new_threshhold)) + if (aligned_new_threshold > 1 + && !pow2p_hwi (aligned_new_threshold)) { - error ("-faligned-new=%d is not a power of two", aligned_new_threshhold); - aligned_new_threshhold = 1; + error ("-faligned-new=%d is not a power of two", aligned_new_threshold); + aligned_new_threshold = 1; } - if (aligned_new_threshhold == -1) - aligned_new_threshhold = (cxx_dialect >= cxx1z) ? 1 : 0; - if (aligned_new_threshhold == 1) - aligned_new_threshhold = max_align_t_align () / BITS_PER_UNIT; + if (aligned_new_threshold == -1) + aligned_new_threshold = (cxx_dialect >= cxx1z) ? 1 : 0; + if (aligned_new_threshold == 1) + aligned_new_threshold = max_align_t_align () / BITS_PER_UNIT; { tree newattrs, extvisattr; @@ -4210,7 +4210,7 @@ cxx_init_decl_processing (void) push_cp_library_fn (VEC_DELETE_EXPR, deltype, ECF_NOTHROW); } - if (aligned_new_threshhold) + if (aligned_new_threshold) { push_namespace (std_identifier); tree align_id = get_identifier ("align_val_t"); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index e869542e757..c64ec3f2912 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2574,8 +2574,8 @@ warn_placement_new_too_small (tree type, tree nelts, tree size, tree oper) bool type_has_new_extended_alignment (tree t) { - return (aligned_new_threshhold - && TYPE_ALIGN_UNIT (t) > (unsigned)aligned_new_threshhold); + return (aligned_new_threshold + && TYPE_ALIGN_UNIT (t) > (unsigned)aligned_new_threshold); } /* Generate code for a new-expression, including calling the "operator @@ -3026,8 +3026,9 @@ build_new_1 (vec **placement, tree type, tree nelts, "alignment %d", elt_type, TYPE_ALIGN_UNIT (elt_type)); inform (input_location, "uses %qD, which does not have an alignment " "parameter", alloc_fn); - inform (input_location, "use %<-faligned-new%> to enable C++17 " - "over-aligned new support"); + if (!aligned_new_threshold) + inform (input_location, "use %<-faligned-new%> to enable C++17 " + "over-aligned new support"); } /* If we found a simple case of PLACEMENT_EXPR above, then copy it diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 73db6902fc8..77c63e225fd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-09-21 Jakub Jelinek + + PR c++/77651 + * g++.dg/cpp1z/aligned-new6.C: New test. + 2016-09-21 Matthew Wahab * gcc.target/arm/fp16-aapcs-3.c: New. diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new6.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new6.C new file mode 100644 index 00000000000..0daa54f2fb2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new6.C @@ -0,0 +1,14 @@ +// PR c++/77651 +// { dg-do run { target { c++11 && c++14_down } } } +// { dg-options "-faligned-new -W -Wall -Wno-aligned-new" } + +struct alignas(64) A { int i; }; + +int +main () +{ + A *p = new A; + if (((__UINTPTR_TYPE__) p) % 64 != 0) + __builtin_abort (); + delete p; +}