Commit 1c53d72b by Jason Merrill Committed by Jason Merrill

call.c (implicit_conversion): Fix value-init of enums.

	* call.c (implicit_conversion): Fix value-init of enums.
	(convert_like_real): Likewise.

From-SVN: r163897
parent be2b93e6
2010-09-06 Jason Merrill <jason@redhat.com>
* call.c (implicit_conversion): Fix value-init of enums.
(convert_like_real): Likewise.
* decl.c (cp_finish_decl): Don't change init for auto deduction.
* pt.c (fold_non_dependent_expr_sfinae): Split out from...
......
......@@ -1457,7 +1457,7 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p,
tree elt;
if (nelts == 0)
elt = integer_zero_node;
elt = build_value_init (to, tf_none);
else if (nelts == 1)
elt = CONSTRUCTOR_ELT (expr, 0)->value;
else
......@@ -5050,7 +5050,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
{
int nelts = CONSTRUCTOR_NELTS (expr);
if (nelts == 0)
expr = integer_zero_node;
expr = build_value_init (totype, tf_warning_or_error);
else if (nelts == 1)
expr = CONSTRUCTOR_ELT (expr, 0)->value;
else
......
2010-09-06 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/initlist42.C: New.
* g++.dg/cpp0x/auto19.C: New.
* g++.dg/template/sfinae25.C: New.
......
// { dg-options -std=c++0x }
enum Unscoped { };
enum class Scoped { };
Unscoped bar(Unscoped x) { return x; }
Scoped bar(Scoped x) { return x; }
auto var1u = bar(Unscoped()); // OK
auto var1s = bar(Scoped()); // OK
auto var2u = bar(Unscoped{}); // #1 Error, but should work
auto var2s = bar(Scoped{}); // #2 Error, but should work
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