18 lines · cpp
1// RUN: %clang_cc1 -std=c++1y -fsyntax-only -verify %s -DMAX=1234 -fconstexpr-steps=12342// RUN: %clang_cc1 -std=c++1y -fsyntax-only -verify %s -DMAX=10 -fconstexpr-steps=103// RUN: %clang -std=c++1y -fsyntax-only -Xclang -verify %s -DMAX=12345 -fconstexpr-steps=123454 5// This takes a total of n + 4 steps according to our current rules:6// - One for the compound-statement that is the function body7// - One for the 'for' statement8// - One for the 'int k = 0;' statement9// - One for each of the n evaluations of the compound-statement in the 'for' body10// - One for the 'return' statemnet11constexpr bool steps(int n) {12 for (int k = 0; k != n; ++k) {}13 return true; // expected-note {{step limit}}14}15 16static_assert(steps((MAX - 4)), ""); // ok17static_assert(steps((MAX - 3)), ""); // expected-error {{constant}} expected-note{{call}}18