From 34d57a10c49908f4f7cec83790d56fb3d51f3ccc Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 20 Apr 2017 19:02:05 +0100 Subject: [PATCH] PR c++/80473 allow suppressing notes about over-aligned new gcc/cp: PR c++/80473 * init.c (build_new_1): Suppress notes about over-aligned new when the warning is suppressed. gcc/testsuite: PR c++/80473 * g++.dg/diagnostic/pr80473.C: New test. From-SVN: r247033 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/init.c | 16 +++++++++------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/diagnostic/pr80473.C | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/diagnostic/pr80473.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d90c298..5e14c41 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-04-20 Jonathan Wakely + + PR c++/80473 + * init.c (build_new_1): Suppress notes about over-aligned new when + the warning is suppressed. + 2017-04-20 Volker Reichelt * parser.c (cp_parser_member_declaration): Add warning with fixit diff --git a/gcc/cp/init.c b/gcc/cp/init.c index bfa9020..e9c39ff 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3126,13 +3126,15 @@ build_new_1 (vec **placement, tree type, tree nelts, || CP_DECL_CONTEXT (alloc_fn) == global_namespace) && !aligned_allocation_fn_p (alloc_fn)) { - warning (OPT_Waligned_new_, "% of type %qT with extended " - "alignment %d", elt_type, TYPE_ALIGN_UNIT (elt_type)); - inform (input_location, "uses %qD, which does not have an alignment " - "parameter", alloc_fn); - if (!aligned_new_threshold) - inform (input_location, "use %<-faligned-new%> to enable C++17 " - "over-aligned new support"); + if (warning (OPT_Waligned_new_, "% of type %qT with extended " + "alignment %d", elt_type, TYPE_ALIGN_UNIT (elt_type))) + { + inform (input_location, "uses %qD, which does not have an alignment " + "parameter", alloc_fn); + 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 a91c989..2db3322 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-20 Jonathan Wakely + + PR c++/80473 + * g++.dg/diagnostic/pr80473.C: New test. + 2017-04-20 Volker Reichelt * g++.dg/warn/Wextra-semi.C: New test. diff --git a/gcc/testsuite/g++.dg/diagnostic/pr80473.C b/gcc/testsuite/g++.dg/diagnostic/pr80473.C new file mode 100644 index 0000000..8721213 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr80473.C @@ -0,0 +1,16 @@ +// { dg-options "-Wall -w" } +// { dg-do compile { target c++11 } } +// { dg-bogus "over-aligned new" "PR c++/80473" { target *-*-* } 0 } + +template T&& declval(); + +template +struct is_constructible { enum { value = 0 }; }; + +template +struct is_constructible()), void())> +{ enum { value = 1 }; }; + +struct alignas(64) A { int i; }; + +constexpr bool b = is_constructible::value; -- 2.7.4