Message ID | 4FAA6138.30201@oracle.com |
---|---|
State | New |
Headers | show |
On 05/09/2012 08:21 AM, Paolo Carlini wrote: > Is unapplied because I was really nervous due to the wrong location > (thus caret) of the error call, at the end of the whole condition. Now, > I'm wondering, shall we consistently use error_at (location_of (expr), > ... for the error messages produced by the *convert* functions? Sure. Note that as an alternative to error_at (location_of (expr) you can just use %q+E; the + means "use the location of this argument". > The > below quick fix makes me *much* more happy, the caret points to the > closed round brace of the b() call. Can I trust all the exprs to come > with an embedded location *at least* as accurate as input_location, > normally better? I would think so, yes. If an expression doesn't have a location, location_of/%q+E will just use input_location. Jason
On 9 May 2012 14:59, Jason Merrill <jason@redhat.com> wrote: > On 05/09/2012 08:21 AM, Paolo Carlini wrote: >> >> Is unapplied because I was really nervous due to the wrong location >> (thus caret) of the error call, at the end of the whole condition. Now, >> I'm wondering, shall we consistently use error_at (location_of (expr), >> ... for the error messages produced by the *convert* functions? > > > Sure. Note that as an alternative to error_at (location_of (expr) you can > just use %q+E; the + means "use the location of this argument". This far less clear than error_at(location, "whatever"). And it requires the diagnostics machinery to know about input_location. I removed %H precisely for those reasons. Please, let's stop using "+" in diagnostics and always use explicit locations. Cheers, Manuel.
On 05/09/2012 09:04 AM, Manuel López-Ibáñez wrote: > This far less clear than error_at(location, "whatever"). And it > requires the diagnostics machinery to know about input_location. I > removed %H precisely for those reasons. Please, let's stop using "+" > in diagnostics and always use explicit locations. OK. Jason
Index: testsuite/g++.dg/cpp0x/lambda/lambda-err2.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-err2.C (revision 0) +++ testsuite/g++.dg/cpp0x/lambda/lambda-err2.C (revision 0) @@ -0,0 +1,12 @@ +// PR c++/53158 +// { dg-do compile { target c++11 } } + +int main() +{ + auto a = []() { return true; }; + auto b = []() { return a(); }; // { dg-error "'a' is not captured" } + int c, d; + while (b() && c < d) // { dg-error "could not convert" } + { + } +} Index: cp/cvt.c =================================================================== --- cp/cvt.c (revision 187280) +++ cp/cvt.c (working copy) @@ -743,6 +743,12 @@ ocp_convert (tree type, tree expr, int convtype, i } if (code == BOOLEAN_TYPE) { + if (TREE_CODE (intype) == VOID_TYPE) + { + error ("could not convert %qE from %<void%> to %<bool%>", expr); + return error_mark_node; + } + /* We can't implicitly convert a scoped enum to bool, so convert to the underlying type first. */ if (SCOPED_ENUM_P (intype) && (convtype & CONV_STATIC))