Message ID | mptv9uqznc1.fsf@arm.com |
---|---|
State | New |
Headers | show |
Series | [C++] Protect call to copy_attributes_to_builtin (PR91505) | expand |
On Wed, Aug 21, 2019 at 2:59 PM Richard Sandiford <richard.sandiford@arm.com> wrote: > > copy_attributes_to_builtin only handles BUILT_IN_NORMAL, but C++ was > calling it immediately after the: > > if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL) > > block. The corresponding C code calls it inside the block instead. > > Tested on x86_64-linux-gnu. OK to install? OK (looks even obvious). Richard. > Richard > > > 2019-08-21 Richard Sandiford <richard.sandiford@arm.com> > > gcc/cp/ > PR c++/91505 > * decl.c (duplicate_decls): Call copy_attributes_to_builtin inside > the BUILT_IN_NORMAL block rather than afterward. > > gcc/testsuite/ > PR c++/91505 > * g++.target/i386/crc32-4.C: New test. > > Index: gcc/cp/decl.c > =================================================================== > --- gcc/cp/decl.c 2019-08-15 15:26:04.740237801 +0100 > +++ gcc/cp/decl.c 2019-08-21 13:57:57.336587359 +0100 > @@ -2565,9 +2565,9 @@ duplicate_decls (tree newdecl, tree oldd > set_builtin_decl_declared_p (fncode, true); > break; > } > - } > > - copy_attributes_to_builtin (newdecl); > + copy_attributes_to_builtin (newdecl); > + } > } > if (new_defines_function) > /* If defining a function declared with other language > Index: gcc/testsuite/g++.target/i386/crc32-4.C > =================================================================== > --- /dev/null 2019-07-30 08:53:31.317691683 +0100 > +++ gcc/testsuite/g++.target/i386/crc32-4.C 2019-08-21 13:57:57.336587359 +0100 > @@ -0,0 +1,4 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -mavx2" } */ > + > +#include "../../gcc.target/i386/crc32-4.c"
Index: gcc/cp/decl.c =================================================================== --- gcc/cp/decl.c 2019-08-15 15:26:04.740237801 +0100 +++ gcc/cp/decl.c 2019-08-21 13:57:57.336587359 +0100 @@ -2565,9 +2565,9 @@ duplicate_decls (tree newdecl, tree oldd set_builtin_decl_declared_p (fncode, true); break; } - } - copy_attributes_to_builtin (newdecl); + copy_attributes_to_builtin (newdecl); + } } if (new_defines_function) /* If defining a function declared with other language Index: gcc/testsuite/g++.target/i386/crc32-4.C =================================================================== --- /dev/null 2019-07-30 08:53:31.317691683 +0100 +++ gcc/testsuite/g++.target/i386/crc32-4.C 2019-08-21 13:57:57.336587359 +0100 @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx2" } */ + +#include "../../gcc.target/i386/crc32-4.c"