]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix target/70107, another case of PR c++/70096
authorAlan Modra <amodra@gmail.com>
Tue, 12 Apr 2016 22:59:05 +0000 (08:29 +0930)
committerAlan Modra <amodra@gcc.gnu.org>
Tue, 12 Apr 2016 22:59:05 +0000 (08:29 +0930)
gcc/cp/
PR target/70107
PR c++/70096
* pt.c (tsubst_decl): Clear the DECL_MODE of the new decl.

gcc/testsuite/
* g++.dg/template/ptrmem30.C (read): Rename to data_read.
(Holder::foo): Reflect this.

PR c++/70096
* g++.dg/template/ptrmem30.C: New test.

From-SVN: r234925

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/ptrmem30.C [new file with mode: 0644]

index 2f565db17f5d562db8770c271e5668556185b40a..3c172ee27b12057be5306d8823880fd63e6b78e6 100644 (file)
@@ -1,3 +1,11 @@
+2016-04-13  Alan Modra  <amodra@gmail.com>
+
+       Backport from mainline
+       2016-03-22  Patrick Palka  <ppalka@gcc.gnu.org>
+       PR target/70107
+       PR c++/70096
+       * pt.c (tsubst_decl): Clear the DECL_MODE of the new decl.
+
 2016-03-18  Jonathan Wakely  <jwakely@redhat.com>
 
        Backported from mainline
index cece89ea30125d543ee65ca4d217b403d9eab947..4b4cf4ec20bd3a002f5a79879771575f7569d5a4 100644 (file)
@@ -11164,6 +11164,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
        /* The initializer must not be expanded until it is required;
           see [temp.inst].  */
        DECL_INITIAL (r) = NULL_TREE;
+       if (VAR_P (r))
+         DECL_MODE (r) = VOIDmode;
        if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL))
          SET_DECL_RTL (r, NULL);
        DECL_SIZE (r) = DECL_SIZE_UNIT (r) = 0;
index 8676cd5d1185dced0d918cfd40d8341db3eb5128..ba7723a47892246be9d120c7e8cfbfe712281a74 100644 (file)
@@ -1,3 +1,14 @@
+2016-04-13  Alan Modra  <amodra@gmail.com>
+
+       Backport from mainline
+       2016-03-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+       * g++.dg/template/ptrmem30.C (read): Rename to data_read.
+       (Holder::foo): Reflect this.
+
+       2016-03-22  Patrick Palka  <ppalka@gcc.gnu.org>
+       PR c++/70096
+       * g++.dg/template/ptrmem30.C: New test.
+
 2016-04-11  Alan Modra  <amodra@gmail.com>
 
        * gcc.target/powerpc/pr70117.c: New.
diff --git a/gcc/testsuite/g++.dg/template/ptrmem30.C b/gcc/testsuite/g++.dg/template/ptrmem30.C
new file mode 100644 (file)
index 0000000..31e9b5d
--- /dev/null
@@ -0,0 +1,45 @@
+// PR c++/70096
+// { dg-do run }
+
+int data_read;
+
+struct Holder
+{
+  void foo () { data_read = data; }
+  int data;
+};
+
+void
+poison_stack ()
+{
+  volatile char a[256];
+  __builtin_memset ((void *)a, 0xa, sizeof a);
+}
+
+template <typename F>
+void test1 ()
+{
+  Holder h;
+  h.data = 42;
+  F Holder::*fptr = &Holder::foo;
+  (h.*fptr)();
+}
+
+template <typename F>
+void test2 ()
+{
+  Holder h;
+  h.data = 42;
+  F Holder::*fptr1 = &Holder::foo;
+  F Holder::*fptr2 = fptr1;
+  (h.*fptr2)();
+}
+
+
+int main ()
+{
+  poison_stack ();
+  test1<void()>();
+  poison_stack ();
+  test2<void()>();
+}