re PR c++/3698 (improper handling of an extern declared inline function)
authorJakub Jelinek <jakub@redhat.com>
Mon, 16 Jul 2018 07:43:43 +0000 (09:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 16 Jul 2018 07:43:43 +0000 (09:43 +0200)
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
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr3698.C [new file with mode: 0644]

index 1d5d66946f61cbd80333fc90882b0b231c911899..a8bd6b2f7178d27da4802466e59cdcb3e9c365a5 100644 (file)
@@ -1,3 +1,10 @@
+2018-07-16  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <nathan@acm.org>
 
        PR c++/86374
index 145af26f18db6b36a4ed3d2d39d49d48816be2f1..356b188e00b9d0c4f833696e4f2e5be219b4cdc2 100644 (file)
@@ -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;
        }
index 3eee55cd6c924d28cf7de33c25850c86204af9e4..9b6fe46edfac882ee1a754a90d7e91693f6b31cc 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/3698
+       PR c++/86208
+       * g++.dg/opt/pr3698.C: New test.
+
 2018-07-16  Richard Biener  <rguenther@suse.de>
 
        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 (file)
index 0000000..ebdf573
--- /dev/null
@@ -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);
+}