Message ID | 20181012145905.GL11625@tucnak |
---|---|
State | New |
Headers | show |
Series | Backports to gcc-7-branch | expand |
--- gcc/cp/cp-gimplify.c (revision 262678) +++ gcc/cp/cp-gimplify.c (revision 262679) @@ -1085,6 +1085,7 @@ cp_genericize_r (tree *stmt_p, int *walk if (h) { *stmt_p = h->to; + TREE_USED (h->to) |= TREE_USED (stmt); *walk_subtrees = 0; return NULL; } --- gcc/testsuite/g++.dg/opt/pr3698.C (nonexistent) +++ gcc/testsuite/g++.dg/opt/pr3698.C (revision 262679) @@ -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); +}