On 7 May 2012 19:40, Paolo Carlini <paolo.carl...@oracle.com> wrote:
> On 05/07/2012 07:18 PM, Paolo Carlini wrote:
>
> a.cc:5:12: error: could not convert ‘foo()’ from ‘void’ to ‘bool’
>   if (foo())
>
> Is this the error message we want to see for the former testcase, or we want
> something slightly different?

If "foo()" is printed with %qE, and now that we have caret
diagnostics, I would expect the message to be:

error: could not convert expression from 'void' to 'bool'

For comparison, this is what Clang gives:

/tmp/webcompile/_8320_0.cc:7:6: error: value of type 'void' is not
contextually convertible to 'bool'
 if (foo() && a < b)
     ^~~~~
/tmp/webcompile/_8320_0.cc:7:12: error: invalid operands to binary
expression ('void' and 'bool')
 if (foo() && a < b)
     ~~~~~ ^  ~~~~~
2 errors generated.


G++ could do better in this case, foo() is likely to be some kind of
FUNCTION_DECL, so g++ could be smarter and say something like:

error: could not convert return type of 'foo' from 'void' to 'bool'
note: 'foo' declared here

Just a suggestion.

Cheers,

Manuel.

Reply via email to