]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/3698 (improper handling of an extern declared inline function)
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Oct 2018 17:27:56 +0000 (19:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Oct 2018 17:27:56 +0000 (19:27 +0200)
Backported from mainline
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.

* g++.dg/opt/pr3698.C: New test.

From-SVN: r265115

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr3698.C [new file with mode: 0644]

index 738b043732a33cd5442afe39a23ce66af83efb4f..800856077a2f8019d3d5a1d39f9837f352839c37 100644 (file)
@@ -1,3 +1,13 @@
+2018-10-12  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-06-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/86291
index 58037e56e6c44adb6e51d6adc82e85a31411182c..e071569b79494d36c06b797abdca77ab597475c3 100644 (file)
@@ -1064,6 +1064,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 f933ad258115deb153b0a7e1ec2bf5c8f49df8c9..29b048361a5fdd5e971f41b674ce603ce94229f6 100644 (file)
@@ -1,3 +1,12 @@
+2018-10-12  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2018-07-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/3698
+       PR c++/86208
+       * g++.dg/opt/pr3698.C: New test.
+
 2018-10-12  Richard Biener  <rguenther@suse.de>
 
        PR c++/54278
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);
+}