From: Alan Modra Date: Tue, 12 Apr 2016 22:59:05 +0000 (+0930) Subject: Fix target/70107, another case of PR c++/70096 X-Git-Tag: releases/gcc-4.9.4~226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5efd8676e844a9bf6fc4a29b9d517869e7123f20;p=thirdparty%2Fgcc.git Fix target/70107, another case of PR c++/70096 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2f565db17f5d..3c172ee27b12 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2016-04-13 Alan Modra + + Backport from mainline + 2016-03-22 Patrick Palka + PR target/70107 + PR c++/70096 + * pt.c (tsubst_decl): Clear the DECL_MODE of the new decl. + 2016-03-18 Jonathan Wakely Backported from mainline diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cece89ea3012..4b4cf4ec20bd 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8676cd5d1185..ba7723a47892 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2016-04-13 Alan Modra + + Backport from mainline + 2016-03-31 Rainer Orth + * g++.dg/template/ptrmem30.C (read): Rename to data_read. + (Holder::foo): Reflect this. + + 2016-03-22 Patrick Palka + PR c++/70096 + * g++.dg/template/ptrmem30.C: New test. + 2016-04-11 Alan Modra * 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 index 000000000000..31e9b5d17f61 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ptrmem30.C @@ -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 +void test1 () +{ + Holder h; + h.data = 42; + F Holder::*fptr = &Holder::foo; + (h.*fptr)(); +} + +template +void test2 () +{ + Holder h; + h.data = 42; + F Holder::*fptr1 = &Holder::foo; + F Holder::*fptr2 = fptr1; + (h.*fptr2)(); +} + + +int main () +{ + poison_stack (); + test1(); + poison_stack (); + test2(); +}