Message ID | 20180703073555.GX7166@tucnak |
---|---|
State | New |
Headers | show |
Series | [C++] Fix extern_decl_map handling (PR c++/3698, PR c++/86208) | expand |
--- gcc/cp/cp-gimplify.c.jj 2018-06-20 08:15:28.980857357 +0200 +++ gcc/cp/cp-gimplify.c 2018-07-02 18:03:00.714313555 +0200 @@ -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.jj 2018-07-02 18:05:52.535479087 +0200 +++ gcc/testsuite/g++.dg/opt/pr3698.C 2018-07-02 18:05:44.507471531 +0200 @@ -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); +}