PR c++/80473 allow suppressing notes about over-aligned new
authorJonathan Wakely <jwakely@redhat.com>
Thu, 20 Apr 2017 18:02:05 +0000 (19:02 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 20 Apr 2017 18:02:05 +0000 (19:02 +0100)
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
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/pr80473.C [new file with mode: 0644]

index d90c2985f0495baebe788b1e2cf40ab16c2e3b99..5e14c411b71959b7f71e41daf53bb7b1dff6ff62 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-20  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR c++/80473
+       * init.c (build_new_1): Suppress notes about over-aligned new when
+       the warning is suppressed.
+
 2017-04-20  Volker Reichelt  <v.reichelt@netcologne.de>
 
        * parser.c (cp_parser_member_declaration): Add warning with fixit
index bfa902050cbbed0b03168a66832bcb777e2f2f7d..e9c39ff25e6df09d8bedb454e6949a323ba2e7ed 100644 (file)
@@ -3126,13 +3126,15 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
          || CP_DECL_CONTEXT (alloc_fn) == global_namespace)
       && !aligned_allocation_fn_p (alloc_fn))
     {
-      warning (OPT_Waligned_new_, "%<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_, "%<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
index a91c9891da62e1e399949b9e37e5eaee9558575b..2db33222a390a676c6a5a24eace9d52d48483b6a 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-20  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR c++/80473
+       * g++.dg/diagnostic/pr80473.C: New test.
+
 2017-04-20  Volker Reichelt  <v.reichelt@netcologne.de>
 
        * 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 (file)
index 0000000..8721213
--- /dev/null
@@ -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<typename T> T&& declval();
+
+template<typename T, typename U, typename = void>
+struct is_constructible { enum { value = 0 }; };
+
+template<typename T, typename U>
+struct is_constructible<T, U, decltype(::new T(declval<U>()), void())>
+{ enum { value = 1 }; };
+
+struct alignas(64) A { int i; };
+
+constexpr bool b = is_constructible<A, A>::value;