From 214931020be4420e7a5eb537813dc918b9cada58 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez?= Date: Thu, 15 Feb 2007 22:15:20 +0000 Subject: [PATCH] re PR c++/28943 (Unusable error message when using a conditional-expression with multiple type arguments) 2007-02-15 Manuel Lopez-Ibanez PR c++/28943 cp/ * call.c (build_conditional_expr): Improve error message. testsuite/ * g++.dg/warn/pr28943.C: New. From-SVN: r122016 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 12 ++++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/warn/pr28943.C | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/pr28943.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 342a7ba7a28..fd068e4155b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2007-02-15 Manuel Lopez-Ibanez + + PR c++/28943 + * call.c (build_conditional_expr): Improve error message. + 2007-02-13 Dirk Mueller * friend.c (do_friend): Annotate warning about friend diff --git a/gcc/cp/call.c b/gcc/cp/call.c index ac29ecdbcef..6690fa2a389 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3281,8 +3281,16 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3) result_type = void_type_node; else { - error ("%qE has type % and is not a throw-expression", - VOID_TYPE_P (arg2_type) ? arg2 : arg3); + if (VOID_TYPE_P (arg2_type)) + error ("second operand to the conditional operator " + "is of type %, " + "but the third operand is neither a throw-expression " + "nor of type %"); + else + error ("third operand to the conditional operator " + "is of type %, " + "but the second operand is neither a throw-expression " + "nor of type %"); return error_mark_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 91420fc94e8..b876518ecee 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-02-15 Manuel Lopez-Ibanez + + PR c++/28943 + * g++.dg/warn/pr28943.C: New. + 2007-02-15 Jerry DeLisle * gfortran.fortran-torture/execute/math.f90: Fix typo. diff --git a/gcc/testsuite/g++.dg/warn/pr28943.C b/gcc/testsuite/g++.dg/warn/pr28943.C new file mode 100644 index 00000000000..046312c0e4b --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr28943.C @@ -0,0 +1,15 @@ +// PR c++/28943 void and non-void in conditional expression +// { dg-do compile } +// { dg-options "" } + +void debug (const char * string) +{ + return; +} + +int f() +{ + ( true == false ? 0 : debug ("Some string")); // { dg-error "third operand .* type 'void'.* second operand is neither a throw-expression nor of type 'void'" } + ( true == false ? debug ("Some string") : 0 ); // { dg-error "second operand .* type 'void'.* third operand is neither a throw-expression nor of type 'void'" } + return 0; +} -- 2.30.2