2011-03-16 Jason Merrill <jason@redhat.com>
+ PR c++/48113
+ * typeck.c (convert_for_initialization): Use
+ perform_implicit_conversion_flags.
+ * call.c (standard_conversion): If LOOKUP_PREFER_RVALUE, set
+ rvaluedness_matches_p on ck_rvalue.
+ (convert_like_real) [ck_rvalue]: And restore it here.
+
PR c++/48115
* call.c (convert_arg_to_ellipsis): Handle incomplete type.
BOOL_BITFIELD base_p : 1;
/* If KIND is ck_ref_bind, true when either an lvalue reference is
being bound to an lvalue expression or an rvalue reference is
- being bound to an rvalue expression. */
+ being bound to an rvalue expression. If KIND is ck_rvalue,
+ true when we should treat an lvalue as an rvalue (12.8p33). If
+ KIND is ck_base, always false. */
BOOL_BITFIELD rvaluedness_matches_p: 1;
BOOL_BITFIELD check_narrowing: 1;
/* The type of the expression resulting from the conversion. */
}
}
conv = build_conv (ck_rvalue, from, conv);
+ if (flags & LOOKUP_PREFER_RVALUE)
+ conv->rvaluedness_matches_p = true;
}
/* Allow conversion between `__complex__' data types. */
conversion (i.e. the second step of copy-initialization), so
don't allow any more. */
flags |= LOOKUP_NO_CONVERSION;
+ if (convs->rvaluedness_matches_p)
+ flags |= LOOKUP_PREFER_RVALUE;
if (TREE_CODE (expr) == TARGET_EXPR
&& TARGET_EXPR_LIST_INIT_P (expr))
/* Copy-list-initialization doesn't actually involve a copy. */
return rhs;
if (MAYBE_CLASS_TYPE_P (type))
- return ocp_convert (type, rhs, CONV_IMPLICIT|CONV_FORCE_TEMP, flags);
+ return perform_implicit_conversion_flags (type, rhs, complain, flags);
return convert_for_assignment (type, rhs, errtype, fndecl, parmnum,
complain, flags);
+2011-03-16 Jason Merrill <jason@redhat.com>
+
+ * g++.dg/cpp0x/sfinae6.C: New.
+ * gcc/testsuite/g++.dg/cpp0x/initlist38.C: Adjust expected error.
+ * gcc/testsuite/g++.dg/cpp0x/pr45908.C: Likewise.
+ * gcc/testsuite/g++.dg/cpp0x/sfinae6.C: Likewise.
+ * gcc/testsuite/g++.old-deja/g++.jason/conversion11.C: Likewise.
+ * gcc/testsuite/g++.old-deja/g++.law/arg11.C: Likewise.
+
2011-03-16 Jason Merrill <jason@redhat.com>
* g++.dg/template/incomplete6.C: New.
f({});
B b0 = { };
B b1 { }; // OK, uses #1
- B b2 { 1 }; // { dg-error "conversion" }
+ B b2 { 1 }; // { dg-error "could not convert" }
}
class block {
vector v;
auto end() const -> decltype(v.begin())
- { return v.begin(); } // { dg-error "conversion" }
+ { return v.begin(); } // { dg-error "could not convert" }
};
--- /dev/null
+// PR c++/48113
+// { dg-options -std=c++0x }
+
+template<typename T> T declval();
+
+struct tuple { };
+
+struct F1
+{
+ void operator()(tuple, int);
+};
+
+typedef void (*F2)(tuple, int);
+
+template<typename F, typename T>
+struct Bind
+{
+ template<typename A,
+ typename R = decltype( F()(declval<T&>(), A()) )>
+ R f(A);
+
+ template<typename A,
+ typename R = decltype( F()(declval<volatile T&>(), A()) )>
+ R f(A) volatile;
+};
+
+int main()
+{
+ Bind<F1, tuple>().f(0); // OK
+ Bind<F2, tuple>().f(0); // ERROR, should be OK
+}
void foo(Something* pX)
{
- DoSomething(1); // { dg-error "conversion" }
+ DoSomething(1); // { dg-error "could not convert" }
pX->DoSomething(1); // { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 25 }
(*pX).DoSomething(1); // { dg-error "no matching" }
int
foo(S *o)
{ // Neither call has a usable constructor for conversions of char[5] to Ack.
- function("adsf");// { dg-error "conversion" }
+ function("adsf");// { dg-error "could not convert" }
o->method("adsf");// { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 20 }
return 0;