llvm-project/clang/test/Parser/explicit-bool-pre-cxx17.cpp
Jongmyeong Choi 385f83c774
[clang] Fix assertion failure with explicit(bool) in pre-C++11 modes (#152985)
Allow CCEKind::ExplicitBool in BuildConvertedConstantExpression for
pre-C++11 contexts, similar to the existing TempArgStrict exception.
This enables explicit(bool) to work as a C++20 extension in earlier
language modes without triggering assertion failures.

Fixes #152729

---------

Co-authored-by: Jongmyeong Choi <cheesechoi@gmail.com>
2025-08-13 07:03:09 -07:00

16 lines
518 B
C++

// 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}}
};