From 112eadc76334c1709962ddf47ebf5b11bae685c1 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 18 Nov 2011 15:31:38 +0000 Subject: [PATCH] re PR c++/51150 ([C++11][4.6/4.7 Regression] ICE when result of -> initializes const variable of different type) /cp 2011-11-18 Paolo Carlini PR c++/51150 * pt.c (tsubst_copy_and_build): Handle FIX_TRUNC_EXPR. /testsuite 2011-11-18 Paolo Carlini PR c++/51150 * g++.dg/cpp0x/pr51150.C: New. From-SVN: r181478 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 4 ++++ gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/g++.dg/cpp0x/pr51150.C | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr51150.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 26d3c293da3..c1d347d02bd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-11-18 Paolo Carlini + + PR c++/51150 + * pt.c (tsubst_copy_and_build): Handle FIX_TRUNC_EXPR. + 2011-11-18 Dodji Seketeli PR c++/51191 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 78e263f9e95..987b70b7ba4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13387,6 +13387,10 @@ tsubst_copy_and_build (tree t, return build_x_unary_op (TREE_CODE (t), RECUR (TREE_OPERAND (t, 0)), complain); + case FIX_TRUNC_EXPR: + return cp_build_unary_op (FIX_TRUNC_EXPR, RECUR (TREE_OPERAND (t, 0)), + 0, complain); + case ADDR_EXPR: op1 = TREE_OPERAND (t, 0); if (TREE_CODE (op1) == LABEL_DECL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1edc46c4e19..b22ebc6c861 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-11-18 Paolo Carlini + + PR c++/51150 + * g++.dg/cpp0x/pr51150.C: New. + 2011-11-18 Martin Jambor PR tree-optimization/50605 @@ -16,7 +21,7 @@ 2011-11-17 Andrew MacLeod - * gcc.dg/atomic-generic-aux.c (__atomic_compare_exchange): Fail if + * gcc.dg/atomic-generic-aux.c (__atomic_compare_exchange): Fail if memory model parameters don't match expected values. * gcc.dg/atomic-generic.c: Pass specific memory model parameters to __atomic_compare_exchange. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51150.C b/gcc/testsuite/g++.dg/cpp0x/pr51150.C new file mode 100644 index 00000000000..37eb166b43e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr51150.C @@ -0,0 +1,20 @@ +// PR c++/51150 +// { dg-options "-std=c++0x" } + +struct Clock { + double Now(); +}; +template void Foo(Clock* clock) { + const int now = clock->Now(); +} + +template void Foo(Clock*); + +template void Boo(int val) { + const int now1 = (double)(val); + const int now2 = const_cast(val); // { dg-error "invalid" } + const int now3 = static_cast(val); + const int now4 = reinterpret_cast(val); // { dg-error "invalid" } +} + +template void Boo(int);