]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix PR c++/70096 (wrong code for pointer-to-member-function copy)
authorppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Mar 2016 02:02:01 +0000 (02:02 +0000)
committerppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Mar 2016 02:02:01 +0000 (02:02 +0000)
gcc/cp/ChangeLog:

PR c++/70096
* pt.c (tsubst_decl): Clear the DECL_MODE of the new decl.

gcc/testsuite/ChangeLog:

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234391 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 578fc6fba358909516ec3262f04f1cfa78170437..adf0ddaa72f07fe5d713534844b12b0215f0ecdb 100644 (file)
@@ -1,3 +1,8 @@
+2016-03-22  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/70096
+       * pt.c (tsubst_decl): Clear the DECL_MODE of the new decl.
+
 2016-03-22  Patrick Palka  <ppalka@gcc.gnu.org>
 
        PR c++/70204
index e8cfb660ad06e110522a407b19c1998089ab7057..45cd1eaaf4fd2a05ef4a189d645ce6d7f5b94239 100644 (file)
@@ -12374,6 +12374,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 69c97a7fa360accee15b7da29ac8f7def1999953..dc47ef1a84692d0ac4253f47a13b57e8fbd59f4a 100644 (file)
@@ -1,3 +1,8 @@
+2016-03-22  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/70096
+       * g++.dg/template/ptrmem30.C: New test.
+
 2016-03-22  Patrick Palka  <ppalka@gcc.gnu.org>
 
        PR c++/70204
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..923238b
--- /dev/null
@@ -0,0 +1,45 @@
+// PR c++/70096
+// { dg-do run }
+
+int read;
+
+struct Holder
+{
+  void foo () { 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()>();
+}