From 9e51f66f9b9178499a88f6a4efcaab14d5d02efb Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 16 Jul 2018 09:43:43 +0200 Subject: [PATCH] re PR c++/3698 (improper handling of an extern declared inline function) PR c++/3698 PR c++/86208 * cp-gimplify.c (cp_genericize_r): When using extern_decl_map, or in TREE_USED flag from stmt to h->to. * g++.dg/opt/pr3698.C: New test. From-SVN: r262678 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/cp-gimplify.c | 1 + gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/opt/pr3698.C | 21 +++++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/g++.dg/opt/pr3698.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1d5d66946f6..a8bd6b2f717 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-07-16 Jakub Jelinek + + PR c++/3698 + PR c++/86208 + * cp-gimplify.c (cp_genericize_r): When using extern_decl_map, or + in TREE_USED flag from stmt to h->to. + 2018-07-13 Nathan Sidwell PR c++/86374 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 145af26f18d..356b188e00b 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1085,6 +1085,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) if (h) { *stmt_p = h->to; + TREE_USED (h->to) |= TREE_USED (stmt); *walk_subtrees = 0; return NULL; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3eee55cd6c9..9b6fe46edfa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-07-16 Jakub Jelinek + + PR c++/3698 + PR c++/86208 + * g++.dg/opt/pr3698.C: New test. + 2018-07-16 Richard Biener PR ipa/86389 diff --git a/gcc/testsuite/g++.dg/opt/pr3698.C b/gcc/testsuite/g++.dg/opt/pr3698.C new file mode 100644 index 00000000000..ebdf5731eb3 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr3698.C @@ -0,0 +1,21 @@ +// PR c++/3698 +// { dg-do link } +// { dg-options "-O0" } + +struct X { + int i; +}; + +inline const int& +OHashKey (const X& x) +{ + return x.i; +} + +int +main () +{ + extern const int& OHashKey (const X& x); + X x; + return OHashKey (x); +} -- 2.30.2