re PR c++/28943 (Unusable error message when using a conditional-expression with…

re PR c++/28943 (Unusable error message when using a conditional-expression with multiple type arguments)

2007-02-15  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR c++/28943
cp/
	* call.c (build_conditional_expr): Improve error message.
testsuite/
	* g++.dg/warn/pr28943.C: New.

From-SVN: r122016
parent f173837a
2007-02-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/28943
* call.c (build_conditional_expr): Improve error message.
2007-02-13 Dirk Mueller <dmueller@suse.de>
* friend.c (do_friend): Annotate warning about friend
......
......@@ -3281,8 +3281,16 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
result_type = void_type_node;
else
{
error ("%qE has type %<void%> 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 %<void%>, "
"but the third operand is neither a throw-expression "
"nor of type %<void%>");
else
error ("third operand to the conditional operator "
"is of type %<void%>, "
"but the second operand is neither a throw-expression "
"nor of type %<void%>");
return error_mark_node;
}
......
2007-02-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/28943
* g++.dg/warn/pr28943.C: New.
2007-02-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* gfortran.fortran-torture/execute/math.f90: Fix typo.
// 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment