From 077eb7af6e296e45e8f333f799170685b4d77b03 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 21 Aug 2019 13:59:31 +0000 Subject: [PATCH] [C++] Protect call to copy_attributes_to_builtin (PR91505) 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 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. From-SVN: r274799 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.target/i386/crc32-4.C | 4 ++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.target/i386/crc32-4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c40bc9c15b9..d47c2f74f37 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-08-21 Richard Sandiford + + 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 PR c++/91264 - detect modifying const objects in constexpr. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 08b7baa40e0..88aa69ce5de 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e8d22d1844d..27c5144436d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-21 Richard Sandiford + + PR c++/91505 + * g++.target/i386/crc32-4.C: New test. + 2019-08-21 Richard Biener 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 index 00000000000..542ded64088 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/crc32-4.C @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx2" } */ + +#include "../../gcc.target/i386/crc32-4.c" -- 2.30.2