diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5635,13 +5635,11 @@ // expression is a constant expression and the implicit conversion // sequence contains only [... list of conversions ...]. ImplicitConversionSequence ICS = - CCE == Sema::CCEK_ExplicitBool - ? TryContextuallyConvertToBool(S, From) - : TryCopyInitialization(S, From, T, - /*SuppressUserConversions=*/false, - /*InOverloadResolution=*/false, - /*AllowObjCWritebackConversion=*/false, - /*AllowExplicit=*/false); + TryCopyInitialization(S, From, T, + /*SuppressUserConversions=*/false, + /*InOverloadResolution=*/false, + /*AllowObjCWritebackConversion=*/false, + /*AllowExplicit=*/false); StandardConversionSequence *SCS = nullptr; switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: diff --git a/clang/test/SemaCXX/cxx2a-explicit-bool.cpp b/clang/test/SemaCXX/cxx2a-explicit-bool.cpp --- a/clang/test/SemaCXX/cxx2a-explicit-bool.cpp +++ b/clang/test/SemaCXX/cxx2a-explicit-bool.cpp @@ -727,3 +727,18 @@ Str b = "not so short";// expected-error {{no viable conversion}} } + +namespace P1401 { + +const int *ptr; + +struct S { + explicit(sizeof(char[2])) S(char); // expected-error {{explicit specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}} + explicit(ptr) S(long); // expected-error {{conversion from 'const int *' to 'bool' is not allowed in a converted constant expression}} + explicit(nullptr) S(int); // expected-error {{value of type 'nullptr_t' is not implicitly convertible to 'bool'}} + explicit(42L) S(int, int); // expected-error {{explicit specifier argument evaluates to 42, which cannot be narrowed to type 'bool'}} + explicit(sizeof(char)) S(); + explicit(0) S(char, char); + explicit(1L) S(char, char, char); +}; +} // namespace P1401 diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -1296,7 +1296,7 @@ Narrowing contextual conversions to bool P1401R5 - Clang 13 + Clang 13 Trimming whitespaces before line splicing