[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / constexpr-never-constant.cpp
blob307810ee263ddaaa1634212cd015d7d287ffed03
1 // RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -fcxx-exceptions %s
2 // RUN: %clang_cc1 -fsyntax-only -std=c++23 -Winvalid-constexpr -verify -fcxx-exceptions %s
3 // Note: for a diagnostic that defaults to an error, -Wno-foo -Wfoo will
4 // disable the diagnostic and then re-enable it *as a warning* rather than as
5 // an error. So we manually enable it as an error again with -Werror to keep
6 // the diagnostic checks consistent.
7 // RUN: %clang_cc1 -fsyntax-only -std=c++23 -Wno-invalid-constexpr -Winvalid-constexpr -Werror=invalid-constexpr -verify -fcxx-exceptions %s
9 // RUN: %clang_cc1 -fsyntax-only -Wno-invalid-constexpr -verify=good -fcxx-exceptions %s
10 // RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify=good -fcxx-exceptions %s
11 // RUN: %clang_cc1 -fsyntax-only -std=c++23 -Wno-invalid-constexpr -verify=good -fcxx-exceptions %s
12 // RUN: %clang_cc1 -fsyntax-only -std=c++23 -Winvalid-constexpr -Wno-invalid-constexpr -verify=good -fcxx-exceptions %s
13 // RUN: %clang_cc1 -fsyntax-only -Wno-invalid-constexpr -verify=good -fcxx-exceptions %s
14 // good-no-diagnostics
16 constexpr void func() { // expected-error {{constexpr function never produces a constant expression}}
17 throw 12; // expected-note {{subexpression not valid in a constant expression}}
20 #pragma clang diagnostic push
21 #pragma clang diagnostic ignored "-Winvalid-constexpr"
22 constexpr void other_func() {
23 #pragma clang diagnostic pop
25 throw 12;