Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ Bug Fixes to C++ Support
- Fix the dynamic_cast to final class optimization to correctly handle
casts that are guaranteed to fail (#GH137518).
- Fix bug rejecting partial specialization of variable templates with auto NTTPs (#GH118190).
- Fix a crash when using ``explicit(bool)`` in pre-C++11 language modes. (#GH152729)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6275,7 +6275,9 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From,
QualType T, CCEKind CCE,
NamedDecl *Dest,
APValue &PreNarrowingValue) {
assert((S.getLangOpts().CPlusPlus11 || CCE == CCEKind::TempArgStrict) &&
[[maybe_unused]] bool isCCEAllowedPreCXX11 =
(CCE == CCEKind::TempArgStrict || CCE == CCEKind::ExplicitBool);
assert((S.getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
"converted constant expression outside C++11 or TTP matching");

if (checkPlaceholderForOverload(S, From))
Expand Down
15 changes: 15 additions & 0 deletions clang/test/Parser/explicit-bool-pre-cxx17.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Regression test for assertion failure when explicit(bool) is used in pre-C++20
// Fixes GitHub issue #152729
// RUN: %clang_cc1 -std=c++98 -verify %s
// RUN: %clang_cc1 -std=c++03 -verify %s
// RUN: %clang_cc1 -std=c++11 -verify %s
// RUN: %clang_cc1 -std=c++14 -verify %s
// RUN: %clang_cc1 -std=c++17 -verify %s

struct S {
explicit(true) S(int);
// expected-warning@-1 {{explicit(bool) is a C++20 extension}}

explicit(false) S(float);
// expected-warning@-1 {{explicit(bool) is a C++20 extension}}
};
Loading