Hi,
On 07/10/2014 10:55 PM, Jason Merrill wrote:
Hmm, why aren't we already getting the error from
if (convs->check_narrowing)
check_narrowing (totype, expr);
in convert_like_real? Is it that we need to copy LOOKUP_NO_NARROWING
into convflags in build_user_type_conversion_1?
Ah, ah, thanks. Frankly I noticed that flag but somehow decided to not
focus on it :(
Anyway, certainly build_user_type_conversion_1 can be tweaked as you are
suggesting, the only missing bit is that it doesn't get
LOOKUP_NO_NARROWING in the flags, and cannot figure it out from expr
because it's a TARGET_EXPR at that point. Thus it seems to me we have to
pass it down from, say, check_initializer when init is still a
CONSTRUCTOR and its BRACE_ENCLOSED_INITIALIZER_P (init) is set? I'm
going to test the below... makes sense?
Paolo.
//////////////////
Index: call.c
===================================================================
--- call.c (revision 212431)
+++ call.c (working copy)
@@ -3586,7 +3586,8 @@ build_user_type_conversion_1 (tree totype, tree ex
/* It's OK to bind a temporary for converting constructor arguments, but
not in converting the return value of a conversion operator. */
- convflags = ((flags & LOOKUP_NO_TEMP_BIND) | LOOKUP_NO_CONVERSION);
+ convflags = ((flags & LOOKUP_NO_TEMP_BIND) | LOOKUP_NO_CONVERSION
+ | (flags & LOOKUP_NO_NARROWING));
flags &= ~LOOKUP_NO_TEMP_BIND;
if (ctors)
Index: decl.c
===================================================================
--- decl.c (revision 212431)
+++ decl.c (working copy)
@@ -5707,6 +5707,7 @@ check_initializer (tree decl, tree init, int flags
return NULL_TREE;
}
}
+ flags |= LOOKUP_NO_NARROWING;
}
if (TREE_CODE (decl) == CONST_DECL)