]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[C++] Protect call to copy_attributes_to_builtin (PR91505)
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Aug 2019 13:59:31 +0000 (13:59 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Aug 2019 13:59:31 +0000 (13:59 +0000)
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.

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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274799 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.target/i386/crc32-4.C [new file with mode: 0644]

index c40bc9c15b961282bbda444c39aa13b393c250af..d47c2f74f378802e416f0eb997444ddacf4fb2ef 100644 (file)
@@ -1,3 +1,9 @@
+2019-08-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR c++/91505
+       * decl.c (duplicate_decls): Call copy_attributes_to_builtin inside
+       the BUILT_IN_NORMAL block rather than afterward.
+
 2019-08-19  Marek Polacek  <polacek@redhat.com>
 
        PR c++/91264 - detect modifying const objects in constexpr.
index 08b7baa40e004b78aa6b46240c59403367acb0fb..88aa69ce5debb100898bd07685dc8a186d5e16e3 100644 (file)
@@ -2565,9 +2565,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
                    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 e8d22d1844df3de8d651f16cf27f63a3c8736b95..27c5144436dec8837a40d7ee902b550a6182aed7 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR c++/91505
+       * g++.target/i386/crc32-4.C: New test.
+
 2019-08-21  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/91482
diff --git a/gcc/testsuite/g++.target/i386/crc32-4.C b/gcc/testsuite/g++.target/i386/crc32-4.C
new file mode 100644 (file)
index 0000000..542ded6
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "../../gcc.target/i386/crc32-4.c"