From 0453e74da8230c0b02e42e82df2358331dfc8592 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Mon, 25 Apr 2005 18:08:35 +0000 Subject: [PATCH] re PR c++/21188 (CbcModel.cpp:3571: internal compiler error: in compare_values, at tree-vrp.c:292) 2005-04-25 Andrew Pinski PR C++/21188 * g++.dg/opt/rtti2.C: New test. 2005-04-25 Andrew Pinski PR C++/21188 * rtti.c (ifnonnull): Cast the zero comparison operand to the correct type. From-SVN: r98726 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/rtti.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/opt/rtti2.C | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/opt/rtti2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 07f7daa5f5b..74b00a10b66 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-04-25 Andrew Pinski + + PR C++/21188 + * rtti.c (ifnonnull): Cast the zero comparison operand + to the correct type. + 2005-04-24 Jakub Jelinek PR middle-end/20991 diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 1cad0bda9f4..bff6c952b9a 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -419,7 +419,8 @@ static tree ifnonnull (tree test, tree result) { return build3 (COND_EXPR, TREE_TYPE (result), - build2 (EQ_EXPR, boolean_type_node, test, integer_zero_node), + build2 (EQ_EXPR, boolean_type_node, test, + cp_convert (TREE_TYPE (test), integer_zero_node)), cp_convert (TREE_TYPE (result), integer_zero_node), result); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 479f1f45aad..10f42d1277f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-04-25 Andrew Pinski + + PR C++/21188 + * g++.dg/opt/rtti2.C: New test. + 2005-04-25 Paul Brook Steven G. Kargl diff --git a/gcc/testsuite/g++.dg/opt/rtti2.C b/gcc/testsuite/g++.dg/opt/rtti2.C new file mode 100644 index 00000000000..ebbe3cdfda8 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/rtti2.C @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-O2" } +// We used to ICE in compare_values as the types for a comparison +// were not the same kind of types. + +struct class1 +{ + virtual ~class1 (); +}; +struct class2 : class1 { }; + +void f(class1 * oo) +{ + class2 * oj = dynamic_cast (oo) ; + if (oj) + delete oo; +} -- 2.30.2