* [PATCH] PR c++/80473 allow suppressing notes about over-aligned new
@ 2017-04-20 15:16 Jonathan Wakely
2017-04-20 15:33 ` Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2017-04-20 15:16 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 574 bytes --]
This suppresses the notes about over-aligned new when the
corresponding warning is suppressed, either by -w or because it's in a
system header (as in PR 80390, which I originally tried to fix in the
library).
OK for trunk? And gcc-7-branch after 7.1 is released?
Is this the right place for the new test?
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
* init.c (build_new_1): Suppress notes in system headers.
PR c++/80473
* g++.dg/diagnostic/pr80473.C: New test.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 2120 bytes --]
commit 66697a6551dd13715c2156ac6b2d5969010c12db
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Apr 20 15:24:09 2017 +0100
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.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index bfa9020..2e72451 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -3128,11 +3128,14 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
{
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 (diagnostic_report_warnings_p (global_dc, input_location))
+ {
+ 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/g++.dg/diagnostic/pr80473.C b/gcc/testsuite/g++.dg/diagnostic/pr80473.C
new file mode 100644
index 0000000..6a739f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr80473.C
@@ -0,0 +1,14 @@
+// { 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;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR c++/80473 allow suppressing notes about over-aligned new
2017-04-20 15:16 [PATCH] PR c++/80473 allow suppressing notes about over-aligned new Jonathan Wakely
@ 2017-04-20 15:33 ` Jakub Jelinek
2017-04-20 15:38 ` Jonathan Wakely
2017-04-20 15:39 ` Marek Polacek
0 siblings, 2 replies; 6+ messages in thread
From: Jakub Jelinek @ 2017-04-20 15:33 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-patches, Jason Merrill
On Thu, Apr 20, 2017 at 04:09:20PM +0100, Jonathan Wakely wrote:
> --- a/gcc/cp/init.c
> +++ b/gcc/cp/init.c
> @@ -3128,11 +3128,14 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
> {
> 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 (diagnostic_report_warnings_p (global_dc, input_location))
> + {
> + 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");
> + }
This looks weird. I'd expect instead:
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");
}
That is a standard idiom used if some inform or later warning/error depends
on whether earlier warning/error has been diagnosed.
If that works, this is ok for trunk and 7.1 (we don't have a rc1 yet, it is
ok now).
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR c++/80473 allow suppressing notes about over-aligned new
2017-04-20 15:33 ` Jakub Jelinek
@ 2017-04-20 15:38 ` Jonathan Wakely
2017-04-20 15:39 ` Marek Polacek
1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2017-04-20 15:38 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill
On 20/04/17 17:22 +0200, Jakub Jelinek wrote:
>On Thu, Apr 20, 2017 at 04:09:20PM +0100, Jonathan Wakely wrote:
>> --- a/gcc/cp/init.c
>> +++ b/gcc/cp/init.c
>> @@ -3128,11 +3128,14 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
>> {
>> 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 (diagnostic_report_warnings_p (global_dc, input_location))
>> + {
>> + 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");
>> + }
>
>This looks weird. I'd expect instead:
> 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");
> }
>That is a standard idiom used if some inform or later warning/error depends
>on whether earlier warning/error has been diagnosed.
Aha, thanks.
>If that works, this is ok for trunk and 7.1 (we don't have a rc1 yet, it is
>ok now).
OK, I'll test it now.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR c++/80473 allow suppressing notes about over-aligned new
2017-04-20 15:33 ` Jakub Jelinek
2017-04-20 15:38 ` Jonathan Wakely
@ 2017-04-20 15:39 ` Marek Polacek
2017-04-20 17:17 ` Jonathan Wakely
1 sibling, 1 reply; 6+ messages in thread
From: Marek Polacek @ 2017-04-20 15:39 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jonathan Wakely, gcc-patches, Jason Merrill
On Thu, Apr 20, 2017 at 05:22:00PM +0200, Jakub Jelinek wrote:
> On Thu, Apr 20, 2017 at 04:09:20PM +0100, Jonathan Wakely wrote:
> > --- a/gcc/cp/init.c
> > +++ b/gcc/cp/init.c
> > @@ -3128,11 +3128,14 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
> > {
> > 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 (diagnostic_report_warnings_p (global_dc, input_location))
> > + {
> > + 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");
> > + }
>
> This looks weird. I'd expect instead:
> 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");
> }
> That is a standard idiom used if some inform or later warning/error depends
> on whether earlier warning/error has been diagnosed.
Yes.
> If that works, this is ok for trunk and 7.1 (we don't have a rc1 yet, it is
> ok now).
One more thing, the test passes even without the patch. Did you mean to add
// { dg-options "-Wall -w" }
?
Marek
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR c++/80473 allow suppressing notes about over-aligned new
2017-04-20 15:39 ` Marek Polacek
@ 2017-04-20 17:17 ` Jonathan Wakely
2017-04-20 18:58 ` Jonathan Wakely
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2017-04-20 17:17 UTC (permalink / raw)
To: Marek Polacek; +Cc: Jakub Jelinek, gcc-patches, Jason Merrill
On 20/04/17 17:33 +0200, Marek Polacek wrote:
>On Thu, Apr 20, 2017 at 05:22:00PM +0200, Jakub Jelinek wrote:
>> On Thu, Apr 20, 2017 at 04:09:20PM +0100, Jonathan Wakely wrote:
>> > --- a/gcc/cp/init.c
>> > +++ b/gcc/cp/init.c
>> > @@ -3128,11 +3128,14 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
>> > {
>> > 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 (diagnostic_report_warnings_p (global_dc, input_location))
>> > + {
>> > + 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");
>> > + }
>>
>> This looks weird. I'd expect instead:
>> 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");
>> }
>> That is a standard idiom used if some inform or later warning/error depends
>> on whether earlier warning/error has been diagnosed.
>
>Yes.
>
>> If that works, this is ok for trunk and 7.1 (we don't have a rc1 yet, it is
>> ok now).
>
>One more thing, the test passes even without the patch. Did you mean to add
>// { dg-options "-Wall -w" }
>?
Good catch. My original testcase used <type_traits> but I changed it
to not depend on the library, and didn't fix the dg-options.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR c++/80473 allow suppressing notes about over-aligned new
2017-04-20 17:17 ` Jonathan Wakely
@ 2017-04-20 18:58 ` Jonathan Wakely
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2017-04-20 18:58 UTC (permalink / raw)
To: Marek Polacek; +Cc: Jakub Jelinek, gcc-patches, Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 2173 bytes --]
On 20/04/17 17:43 +0100, Jonathan Wakely wrote:
>On 20/04/17 17:33 +0200, Marek Polacek wrote:
>>On Thu, Apr 20, 2017 at 05:22:00PM +0200, Jakub Jelinek wrote:
>>>On Thu, Apr 20, 2017 at 04:09:20PM +0100, Jonathan Wakely wrote:
>>>> --- a/gcc/cp/init.c
>>>> +++ b/gcc/cp/init.c
>>>> @@ -3128,11 +3128,14 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
>>>> {
>>>> 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 (diagnostic_report_warnings_p (global_dc, input_location))
>>>> + {
>>>> + 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");
>>>> + }
>>>
>>>This looks weird. I'd expect instead:
>>> 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");
>>> }
>>>That is a standard idiom used if some inform or later warning/error depends
>>>on whether earlier warning/error has been diagnosed.
>>
>>Yes.
>>
>>>If that works, this is ok for trunk and 7.1 (we don't have a rc1 yet, it is
>>>ok now).
>>
>>One more thing, the test passes even without the patch. Did you mean to add
>>// { dg-options "-Wall -w" }
>>?
>
>Good catch. My original testcase used <type_traits> but I changed it
>to not depend on the library, and didn't fix the dg-options.
Here's what I'm going to commit. Thanks for the reviews/help :)
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 2322 bytes --]
commit 8a5d42bf7baba903807617e6dd800582514dec0b
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Apr 20 15:24:09 2017 +0100
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.
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<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
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<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;
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-04-20 17:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-20 15:16 [PATCH] PR c++/80473 allow suppressing notes about over-aligned new Jonathan Wakely
2017-04-20 15:33 ` Jakub Jelinek
2017-04-20 15:38 ` Jonathan Wakely
2017-04-20 15:39 ` Marek Polacek
2017-04-20 17:17 ` Jonathan Wakely
2017-04-20 18:58 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).