llvm-project/clang/test/SemaCXX/fold_expr_expansion_limit.cpp
Haojian Wu 9c9974c3cc [clang] Limit the maximum level of fold-expr expansion.
Introduce a new diagnostic, and respect the bracket-depth (256) by default.

Differential Revision: https://reviews.llvm.org/D86936
2020-09-08 15:40:09 +02:00

10 lines
551 B
C++

// RUN: %clang_cc1 -fsyntax-only -fbracket-depth 2 -verify -std=c++17 %s
template <class T, T... V> struct seq {
constexpr bool zero() { return (true && ... && (V == 0)); }; // expected-error {{instantiating fold expression with 3 arguments exceeded expression nesting limit of 2}} \
expected-note {{use -fbracket-depth}}
};
constexpr unsigned N = 3;
auto x = __make_integer_seq<seq, int, N>{};
static_assert(!x.zero(), ""); // expected-note {{in instantiation of member function}}