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  <paolo.carlini@oracle.com>

	PR c++/51150
	* pt.c (tsubst_copy_and_build): Handle FIX_TRUNC_EXPR.

/testsuite
2011-11-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51150
	* g++.dg/cpp0x/pr51150.C: New.

From-SVN: r181478
This commit is contained in:
Paolo Carlini 2011-11-18 15:31:38 +00:00
parent 39cc8c3d6b
commit 112eadc763
4 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2011-11-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51150
* pt.c (tsubst_copy_and_build): Handle FIX_TRUNC_EXPR.
2011-11-18 Dodji Seketeli <dodji@redhat.com> 2011-11-18 Dodji Seketeli <dodji@redhat.com>
PR c++/51191 PR c++/51191

View File

@ -13387,6 +13387,10 @@ tsubst_copy_and_build (tree t,
return build_x_unary_op (TREE_CODE (t), RECUR (TREE_OPERAND (t, 0)), return build_x_unary_op (TREE_CODE (t), RECUR (TREE_OPERAND (t, 0)),
complain); complain);
case FIX_TRUNC_EXPR:
return cp_build_unary_op (FIX_TRUNC_EXPR, RECUR (TREE_OPERAND (t, 0)),
0, complain);
case ADDR_EXPR: case ADDR_EXPR:
op1 = TREE_OPERAND (t, 0); op1 = TREE_OPERAND (t, 0);
if (TREE_CODE (op1) == LABEL_DECL) if (TREE_CODE (op1) == LABEL_DECL)

View File

@ -1,3 +1,8 @@
2011-11-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51150
* g++.dg/cpp0x/pr51150.C: New.
2011-11-18 Martin Jambor <mjambor@suse.cz> 2011-11-18 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/50605 PR tree-optimization/50605
@ -16,7 +21,7 @@
2011-11-17 Andrew MacLeod <amacleod@redhat.com> 2011-11-17 Andrew MacLeod <amacleod@redhat.com>
* 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. memory model parameters don't match expected values.
* gcc.dg/atomic-generic.c: Pass specific memory model parameters to * gcc.dg/atomic-generic.c: Pass specific memory model parameters to
__atomic_compare_exchange. __atomic_compare_exchange.

View File

@ -0,0 +1,20 @@
// PR c++/51150
// { dg-options "-std=c++0x" }
struct Clock {
double Now();
};
template <class T> void Foo(Clock* clock) {
const int now = clock->Now();
}
template void Foo<float>(Clock*);
template <class T> void Boo(int val) {
const int now1 = (double)(val);
const int now2 = const_cast<double>(val); // { dg-error "invalid" }
const int now3 = static_cast<double>(val);
const int now4 = reinterpret_cast<double>(val); // { dg-error "invalid" }
}
template void Boo<float>(int);