diff options
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/ptrmem30.C | 45 |
4 files changed, 57 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 578fc6f..adf0dda 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e8cfb66..45cd1ea 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 69c97a7..dc47ef1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 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. diff --git a/gcc/testsuite/g++.dg/template/ptrmem30.C b/gcc/testsuite/g++.dg/template/ptrmem30.C new file mode 100644 index 0000000..923238b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ptrmem30.C @@ -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()>(); +} |