Commit ca45eca1 by Jason Merrill Committed by Jason Merrill

N3323

	* cvt.c (build_expr_type_conversion): Two conversions that return
	the same type aren't necessarily ambiguous.

From-SVN: r198157
parent d3d50a61
2013-04-22 Jason Merrill <jason@redhat.com>
N3323
* cvt.c (build_expr_type_conversion): Two conversions that return
the same type aren't necessarily ambiguous.
N3648
* parser.c (cp_parser_lambda_introducer): Make lambda capture init
pedwarn unconditional except in C++1y mode.
......
......@@ -1630,17 +1630,24 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
{
if (winner)
{
if (complain)
tree winner_type
= non_reference (TREE_TYPE (TREE_TYPE (winner)));
if (!same_type_ignoring_top_level_qualifiers_p (winner_type,
candidate))
{
error ("ambiguous default type conversion from %qT",
basetype);
error (" candidate conversions include %qD and %qD",
winner, cand);
if (complain)
{
error ("ambiguous default type conversion from %qT",
basetype);
error (" candidate conversions include %qD and %qD",
winner, cand);
}
return error_mark_node;
}
return error_mark_node;
}
else
winner = cand;
winner = cand;
}
}
......
// N3323
#define assert(E) if(!(E))__builtin_abort();
template<class T>
class zero_init
{
public:
zero_init( )
: val( static_cast<T>(0) ) { }
zero_init( T val ) : val( val )
{ }
operator T & ( ) { return val; }
operator T ( ) const { return val; }
private:
T val;
};
void f()
{
zero_init<int*> p; assert( p == 0 );
p = new int(7);
assert( *p == 7 );
delete p; // error!
zero_init<int> i; assert( i == 0 );
i = 7;
assert( i == 7 );
switch( i ) { } // error!
int *vp = new int[i];
}
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