/// isConvertingConstructor - Whether this constructor is a
/// converting constructor (C++ [class.conv.ctor]), which can be
/// used for user-defined conversions.
- bool isConvertingConstructor() const;
+ bool isConvertingConstructor(bool AllowExplicit) const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return true;
}
-bool CXXConstructorDecl::isConvertingConstructor() const {
+bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
// C++ [class.conv.ctor]p1:
// A constructor declared without the function-specifier explicit
// that can be called with a single parameter specifies a
// conversion from the type of its first parameter to the type of
// its class. Such a constructor is called a converting
// constructor.
- if (isExplicit())
+ if (isExplicit() && !AllowExplicit)
return false;
return (getNumParams() == 0 &&
Constructor = cast<CXXConstructorDecl>(*Con);
if ((Kind == IK_Direct) ||
- (Kind == IK_Copy && Constructor->isConvertingConstructor()) ||
+ (Kind == IK_Copy &&
+ Constructor->isConvertingConstructor(/*AllowExplicit=*/false)) ||
(Kind == IK_Default && Constructor->isDefaultConstructor())) {
if (ConstructorTmpl)
AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0,
Constructor = cast<CXXConstructorDecl>(*Con);
if (!Constructor->isInvalidDecl() &&
- Constructor->isConvertingConstructor()) {
+ Constructor->isConvertingConstructor(AllowExplicit)) {
if (ConstructorTmpl)
AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0, &From,
1, CandidateSet,
// RUN: clang-cc -fsyntax-only -verify %s
-struct B { B(bool); };
+struct B { explicit B(bool); };
void f() {
(void)(B)true;
(void)B(true);