From 43e4df5a0bed4833a4812746e5554ed057b6dfd4 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 7 Feb 2018 14:16:04 +0100 Subject: [PATCH] Revert behavior to r251316. 2018-02-07 Martin Liska PR c++/84059. * class.c (add_method): Append argument value. * cp-tree.h (maybe_version_functions): Add new argument. * decl.c (decls_match): Call it if a declaration does not have DECL_FUNCTION_VERSIONED. (maybe_version_functions): record argument is added. 2018-02-07 Martin Liska PR c++/84059. * g++.dg/ext/mv26.C: New test. From-SVN: r257451 --- gcc/cp/ChangeLog | 9 +++++++++ gcc/cp/class.c | 2 +- gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 14 ++++++-------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/mv26.C | 15 +++++++++++++++ 6 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/mv26.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2dc96a3b690..d27b885382a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2018-02-07 Martin Liska + + PR c++/84059. + * class.c (add_method): Append argument value. + * cp-tree.h (maybe_version_functions): Add new argument. + * decl.c (decls_match): Call it if a declaration does not + have DECL_FUNCTION_VERSIONED. + (maybe_version_functions): record argument is added. + 2018-02-05 Marek Polacek * class.c: Remove unused global variables. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 6012b8deff9..44170202abe 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1083,7 +1083,7 @@ add_method (tree type, tree method, bool via_using) /* If these are versions of the same function, process and move on. */ if (TREE_CODE (fn) == FUNCTION_DECL - && maybe_version_functions (method, fn)) + && maybe_version_functions (method, fn, true)) continue; if (DECL_INHERITED_CTOR (method)) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 861efb3053b..a6c75aed33d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6135,7 +6135,7 @@ extern bool note_iteration_stmt_body_start (void); extern void note_iteration_stmt_body_end (bool); extern tree make_lambda_name (void); extern int decls_match (tree, tree, bool = true); -extern bool maybe_version_functions (tree, tree); +extern bool maybe_version_functions (tree, tree, bool); extern tree duplicate_decls (tree, tree, bool); extern tree declare_local_label (tree); extern tree define_label (location_t, tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 01ce9fb6d69..3ccea9e6a45 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1087,7 +1087,9 @@ decls_match (tree newdecl, tree olddecl, bool record_versions /* = true */) && !DECL_EXTERN_C_P (newdecl) && !DECL_EXTERN_C_P (olddecl) && record_versions - && maybe_version_functions (newdecl, olddecl)) + && maybe_version_functions (newdecl, olddecl, + (!DECL_FUNCTION_VERSIONED (newdecl) + || !DECL_FUNCTION_VERSIONED (olddecl)))) return 0; } else if (TREE_CODE (newdecl) == TEMPLATE_DECL) @@ -1145,19 +1147,17 @@ decls_match (tree newdecl, tree olddecl, bool record_versions /* = true */) } /* NEWDECL and OLDDECL have identical signatures. If they are - different versions adjust them and return true. */ + different versions adjust them and return true. + If RECORD is set to true, record function versions. */ bool -maybe_version_functions (tree newdecl, tree olddecl) +maybe_version_functions (tree newdecl, tree olddecl, bool record) { if (!targetm.target_option.function_versions (newdecl, olddecl)) return false; - bool record = false; - if (!DECL_FUNCTION_VERSIONED (olddecl)) { - record = true; DECL_FUNCTION_VERSIONED (olddecl) = 1; if (DECL_ASSEMBLER_NAME_SET_P (olddecl)) mangle_decl (olddecl); @@ -1165,13 +1165,11 @@ maybe_version_functions (tree newdecl, tree olddecl) if (!DECL_FUNCTION_VERSIONED (newdecl)) { - record = true; DECL_FUNCTION_VERSIONED (newdecl) = 1; if (DECL_ASSEMBLER_NAME_SET_P (newdecl)) mangle_decl (newdecl); } - /* Only record if at least one was not already versions. */ if (record) cgraph_node::record_function_versions (olddecl, newdecl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c90dc88453f..42f163ab25d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-07 Martin Liska + + PR c++/84059. + * g++.dg/ext/mv26.C: New test. + 2018-02-07 Tom de Vries * gcc.dg/pr83844.c: Require effective target alloca. diff --git a/gcc/testsuite/g++.dg/ext/mv26.C b/gcc/testsuite/g++.dg/ext/mv26.C new file mode 100644 index 00000000000..1b455130e46 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv26.C @@ -0,0 +1,15 @@ +// PR c++/84059 +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-require-ifunc "" } + +template struct a +{ + int __attribute__ ((target ("arch=ivybridge"))) c (int) {return 1;} + int __attribute__ ((target ("default"))) c (int) { return 2; } +}; +void +d () +{ + a b; + b.c (2); +} -- 2.30.2