mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-05 13:41:18 +08:00
Fix PR c++/70096 (wrong code for pointer-to-member-function copy)
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. From-SVN: r234391
This commit is contained in:
parent
a3e2b43831
commit
16f6d7dc5c
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
45
gcc/testsuite/g++.dg/template/ptrmem30.C
Normal file
45
gcc/testsuite/g++.dg/template/ptrmem30.C
Normal file
@ -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()>();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user