// functions are all the converting constructors (12.3.1) of
// that class. The argument list is the expression-list within
// the parentheses of the initializer.
+ bool SuppressUserConversions = !UserCast;
+ if (Context.hasSameUnqualifiedType(ToType, From->getType()) ||
+ IsDerivedFrom(From->getType(), ToType)) {
+ SuppressUserConversions = false;
+ AllowConversionFunctions = false;
+ }
+
DeclarationName ConstructorName
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ToType).getUnqualifiedType());
Constructor->isConvertingConstructor(AllowExplicit)) {
if (ConstructorTmpl)
AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0, &From,
- 1, CandidateSet,
- /*SuppressUserConversions=*/!UserCast,
- ForceRValue);
+ 1, CandidateSet,
+ SuppressUserConversions, ForceRValue);
else
// Allow one user-defined conversion when user specifies a
// From->ToType conversion via an static cast (c-style, etc).
AddOverloadCandidate(Constructor, &From, 1, CandidateSet,
- /*SuppressUserConversions=*/!UserCast,
- ForceRValue);
+ SuppressUserConversions, ForceRValue);
}
}
}
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang-cc -fsyntax-only -verify %s
class X {
public:
operator bool();
char ch = a; // OK. calls Yb::operator char();
}
+// Test conversion + copy construction.
+class AutoPtrRef { };
+
+class AutoPtr {
+ // FIXME: Using 'unavailable' since we do not have access control yet.
+ // FIXME: The error message isn't so good.
+ AutoPtr(AutoPtr &) __attribute__((unavailable));
+
+public:
+ AutoPtr();
+ AutoPtr(AutoPtrRef);
+
+ operator AutoPtrRef();
+};
+
+AutoPtr make_auto_ptr();
+
+AutoPtr test_auto_ptr(bool Cond) {
+ AutoPtr p1( make_auto_ptr() );
+
+ AutoPtr p;
+ if (Cond)
+ return p; // expected-error{{incompatible type returning}}
+
+ return AutoPtr();
+}
+
+