brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 5756bb6 Raw
34 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -fcxx-exceptions %s2// RUN: %clang_cc1 -fsyntax-only -std=c++23 -Winvalid-constexpr -verify -fcxx-exceptions %s3// Note: for a diagnostic that defaults to an error, -Wno-foo -Wfoo will4// disable the diagnostic and then re-enable it *as a warning* rather than as5// an error. So we manually enable it as an error again with -Werror to keep6// the diagnostic checks consistent.7// RUN: %clang_cc1 -fsyntax-only -std=c++23 -Wno-invalid-constexpr -Winvalid-constexpr -Werror=invalid-constexpr -verify -fcxx-exceptions %s8 9// RUN: %clang_cc1 -fsyntax-only -Wno-invalid-constexpr -verify=good -fcxx-exceptions %s10// RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify=good -fcxx-exceptions %s11// RUN: %clang_cc1 -fsyntax-only -std=c++23 -Wno-invalid-constexpr -verify=good -fcxx-exceptions %s12// RUN: %clang_cc1 -fsyntax-only -std=c++23 -Winvalid-constexpr -Wno-invalid-constexpr -verify=good -fcxx-exceptions %s13// RUN: %clang_cc1 -fsyntax-only -Wno-invalid-constexpr -verify=good -fcxx-exceptions %s14// good-no-diagnostics15 16constexpr void func() { // expected-error {{constexpr function never produces a constant expression}}17  throw 12;             // expected-note {{subexpression not valid in a constant expression}}18}19 20#pragma clang diagnostic push21#pragma clang diagnostic ignored "-Winvalid-constexpr"22constexpr void other_func() {23#pragma clang diagnostic pop24 25  throw 12;26}27 28namespace GH149041 {29  // Make sure these don't trigger the diagnostic.30  extern const bool& b;31  constexpr bool fun1() { return b; }32  constexpr bool fun2(const bool& b) { return b; }33}34