Commit 16f6d7dc by Patrick Palka

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
parent a3e2b438
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
* constexpr.c (non_const_var_error): Check
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P.
......
......@@ -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;
......
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
* g++.dg/cpp0x/constexpr-70204a.C: New test.
* g++.dg/cpp0x/constexpr-70204b.C: New test.
......
// 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()>();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment