diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-07-23 18:44:43 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-07-23 18:44:43 +0000 |
commit | 6cf4d1bca0477bd223c8a368ba4b14d580ef1324 (patch) | |
tree | 2aedf10c630310f865c13f931beff5398ead1c48 | |
parent | a08cb3a3740bf876e2590907900a875ea7e81986 (diff) | |
download | gcc-6cf4d1bca0477bd223c8a368ba4b14d580ef1324.zip gcc-6cf4d1bca0477bd223c8a368ba4b14d580ef1324.tar.gz gcc-6cf4d1bca0477bd223c8a368ba4b14d580ef1324.tar.bz2 |
re PR c++/11517 (g++ fails to properly convert pointer expressions in conditional expressions.)
PR c++/11517
* call.c (build_conditional_expr): Use perform_implicit_conversion
and error_operand_p. Robustify.
* typeck.c (build_unary_op): Use perform_implicit_conversion.
PR c++/11517
* g++.dg/expr/cond2.C: New test.
From-SVN: r69715
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/call.c | 13 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/cond2.C | 12 |
5 files changed, 29 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 45f1751..1ef39bf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2003-07-23 Mark Mitchell <mark@codesourcery.com> + + PR c++/11517 + * call.c (build_conditional_expr): Use perform_implicit_conversion + and error_operand_p. Robustify. + * typeck.c (build_unary_op): Use perform_implicit_conversion. + 2003-07-23 Nathan Sidwell <nathan@codesourcery.com> PR c++/10953 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index cbfc5c3..dddd7b8 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3072,16 +3072,13 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3) The first expr ession is implicitly converted to bool (clause _conv_). */ - arg1 = cp_convert (boolean_type_node, arg1); + arg1 = perform_implicit_conversion (boolean_type_node, arg1); /* If something has already gone wrong, just pass that fact up the tree. */ - if (arg1 == error_mark_node - || arg2 == error_mark_node - || arg3 == error_mark_node - || TREE_TYPE (arg1) == error_mark_node - || TREE_TYPE (arg2) == error_mark_node - || TREE_TYPE (arg3) == error_mark_node) + if (error_operand_p (arg1) + || error_operand_p (arg2) + || error_operand_p (arg3)) return error_mark_node; /* [expr.cond] @@ -3333,6 +3330,8 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3) { result_type = composite_pointer_type (arg2_type, arg3_type, arg2, arg3, "conditional expression"); + if (result_type == error_mark_node) + return error_mark_node; arg2 = perform_implicit_conversion (result_type, arg2); arg3 = perform_implicit_conversion (result_type, arg3); } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 0356cb7aa..eb04f88 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3663,7 +3663,7 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert) break; case TRUTH_NOT_EXPR: - arg = cp_convert (boolean_type_node, arg); + arg = perform_implicit_conversion (boolean_type_node, arg); val = invert_truthvalue (arg); if (arg != error_mark_node) return val; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a87abef..354fa81 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2003-07-23 Mark Mitchell <mark@codesourcery.com> + PR c++/11517 + * g++.dg/expr/cond2.C: New test. + PR optimization/10679 * g++.dg/opt/inline4.C: New test. diff --git a/gcc/testsuite/g++.dg/expr/cond2.C b/gcc/testsuite/g++.dg/expr/cond2.C new file mode 100644 index 0000000..d9c2e70 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cond2.C @@ -0,0 +1,12 @@ +struct Term { }; +struct Boolean : Term { + explicit Boolean(bool); +}; +struct IsZero : Term { + Term *eval(); +}; +Term* +IsZero::eval() +{ + return true ? new Boolean(false) : this; // { dg-error "" } +} |