* [PATCH][C++] Fix PR61004
@ 2014-04-30 12:01 Richard Biener
2014-05-06 10:57 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2014-04-30 12:01 UTC (permalink / raw)
To: gcc-patches
With no longer recording alias subsets using BINFOs we now emit
bogus alias warnings for accessing empty bases. The following
avoids this, accessing those with an incompatible alias-set is
harmless.
Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?
Thanks,
Richard.
2014-04-30 Richard Biener <rguenther@suse.de>
PR c++/61004
* typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing
warnings for accessing empty classes.
* g++.dg/diagnostic/pr61004.C: New testcase.
Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c (revision 209928)
+++ gcc/cp/typeck.c (working copy)
@@ -2921,8 +2921,9 @@ cp_build_indirect_ref (tree ptr, ref_ope
of the result is "T." */
tree t = TREE_TYPE (type);
- if (CONVERT_EXPR_P (ptr)
- || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
+ if ((CONVERT_EXPR_P (ptr)
+ || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
+ && (!CLASS_TYPE_P (t) || !CLASSTYPE_EMPTY_P (t)))
{
/* If a warning is issued, mark it to avoid duplicates from
the backend. This only needs to be done at
Index: gcc/testsuite/g++.dg/diagnostic/pr61004.C
===================================================================
--- gcc/testsuite/g++.dg/diagnostic/pr61004.C (revision 0)
+++ gcc/testsuite/g++.dg/diagnostic/pr61004.C (working copy)
@@ -0,0 +1,11 @@
+// { dg-do compile }
+// { dg-options "-O2 -Wall" }
+
+struct A{ };
+struct B:A{};
+void f(A const&);
+int main()
+{
+ B b;
+ f(b); // { dg-bogus "strict-aliasing" }
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][C++] Fix PR61004
2014-04-30 12:01 [PATCH][C++] Fix PR61004 Richard Biener
@ 2014-05-06 10:57 ` Richard Biener
2014-06-05 12:19 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2014-05-06 10:57 UTC (permalink / raw)
To: gcc-patches
On Wed, 30 Apr 2014, Richard Biener wrote:
>
> With no longer recording alias subsets using BINFOs we now emit
> bogus alias warnings for accessing empty bases. The following
> avoids this, accessing those with an incompatible alias-set is
> harmless.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?
Ping.
> Thanks,
> Richard.
>
> 2014-04-30 Richard Biener <rguenther@suse.de>
>
> PR c++/61004
> * typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing
> warnings for accessing empty classes.
>
> * g++.dg/diagnostic/pr61004.C: New testcase.
>
> Index: gcc/cp/typeck.c
> ===================================================================
> --- gcc/cp/typeck.c (revision 209928)
> +++ gcc/cp/typeck.c (working copy)
> @@ -2921,8 +2921,9 @@ cp_build_indirect_ref (tree ptr, ref_ope
> of the result is "T." */
> tree t = TREE_TYPE (type);
>
> - if (CONVERT_EXPR_P (ptr)
> - || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
> + if ((CONVERT_EXPR_P (ptr)
> + || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
> + && (!CLASS_TYPE_P (t) || !CLASSTYPE_EMPTY_P (t)))
> {
> /* If a warning is issued, mark it to avoid duplicates from
> the backend. This only needs to be done at
> Index: gcc/testsuite/g++.dg/diagnostic/pr61004.C
> ===================================================================
> --- gcc/testsuite/g++.dg/diagnostic/pr61004.C (revision 0)
> +++ gcc/testsuite/g++.dg/diagnostic/pr61004.C (working copy)
> @@ -0,0 +1,11 @@
> +// { dg-do compile }
> +// { dg-options "-O2 -Wall" }
> +
> +struct A{ };
> +struct B:A{};
> +void f(A const&);
> +int main()
> +{
> + B b;
> + f(b); // { dg-bogus "strict-aliasing" }
> +}
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][C++] Fix PR61004
2014-05-06 10:57 ` Richard Biener
@ 2014-06-05 12:19 ` Richard Biener
2014-06-05 12:39 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2014-06-05 12:19 UTC (permalink / raw)
To: Richard Biener; +Cc: GCC Patches, Jason Merrill
On Tue, May 6, 2014 at 12:55 PM, Richard Biener <rguenther@suse.de> wrote:
> On Wed, 30 Apr 2014, Richard Biener wrote:
>
>>
>> With no longer recording alias subsets using BINFOs we now emit
>> bogus alias warnings for accessing empty bases. The following
>> avoids this, accessing those with an incompatible alias-set is
>> harmless.
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?
>
> Ping.
Ping.
Thanks,
RIchard.
>> Thanks,
>> Richard.
>>
>> 2014-04-30 Richard Biener <rguenther@suse.de>
>>
>> PR c++/61004
>> * typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing
>> warnings for accessing empty classes.
>>
>> * g++.dg/diagnostic/pr61004.C: New testcase.
>>
>> Index: gcc/cp/typeck.c
>> ===================================================================
>> --- gcc/cp/typeck.c (revision 209928)
>> +++ gcc/cp/typeck.c (working copy)
>> @@ -2921,8 +2921,9 @@ cp_build_indirect_ref (tree ptr, ref_ope
>> of the result is "T." */
>> tree t = TREE_TYPE (type);
>>
>> - if (CONVERT_EXPR_P (ptr)
>> - || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
>> + if ((CONVERT_EXPR_P (ptr)
>> + || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
>> + && (!CLASS_TYPE_P (t) || !CLASSTYPE_EMPTY_P (t)))
>> {
>> /* If a warning is issued, mark it to avoid duplicates from
>> the backend. This only needs to be done at
>> Index: gcc/testsuite/g++.dg/diagnostic/pr61004.C
>> ===================================================================
>> --- gcc/testsuite/g++.dg/diagnostic/pr61004.C (revision 0)
>> +++ gcc/testsuite/g++.dg/diagnostic/pr61004.C (working copy)
>> @@ -0,0 +1,11 @@
>> +// { dg-do compile }
>> +// { dg-options "-O2 -Wall" }
>> +
>> +struct A{ };
>> +struct B:A{};
>> +void f(A const&);
>> +int main()
>> +{
>> + B b;
>> + f(b); // { dg-bogus "strict-aliasing" }
>> +}
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][C++] Fix PR61004
2014-06-05 12:19 ` Richard Biener
@ 2014-06-05 12:39 ` Jason Merrill
0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2014-06-05 12:39 UTC (permalink / raw)
To: Richard Biener, Richard Biener; +Cc: GCC Patches
OK.
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-05 12:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30 12:01 [PATCH][C++] Fix PR61004 Richard Biener
2014-05-06 10:57 ` Richard Biener
2014-06-05 12:19 ` Richard Biener
2014-06-05 12:39 ` Jason Merrill
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).