17d274140SRoman Lebedev // RUN: %clang_cc1 %s -emit-llvm-only -o -
24aaf1dcaSRoman Lebedev
34aaf1dcaSRoman Lebedev // https://bugs.llvm.org/show_bug.cgi?id=38356
44aaf1dcaSRoman Lebedev // We only check that we do not crash.
54aaf1dcaSRoman Lebedev
6*6c7687edSErik Pilkington // This test can exceed stack usage in some configurations, so unless we can
7*6c7687edSErik Pilkington // properly handle that don't run it.
8*6c7687edSErik Pilkington // REQUIRES: thread_support
9536a5c46SVolodymyr Sapsai
104aaf1dcaSRoman Lebedev template <typename a, a b(unsigned), int c, unsigned...>
114aaf1dcaSRoman Lebedev struct d : d<a, b, c - 1> {};
124aaf1dcaSRoman Lebedev template <typename a, a b(unsigned), unsigned... e>
134aaf1dcaSRoman Lebedev struct d<a, b, 0, e...> {
144aaf1dcaSRoman Lebedev a f[0];
154aaf1dcaSRoman Lebedev };
164aaf1dcaSRoman Lebedev struct g {
174aaf1dcaSRoman Lebedev static g h(unsigned);
184aaf1dcaSRoman Lebedev };
194aaf1dcaSRoman Lebedev struct i {
204aaf1dcaSRoman Lebedev void j() const;
214aaf1dcaSRoman Lebedev // Current maximum depth of recursive template instantiation is 1024,
224aaf1dcaSRoman Lebedev // thus, this \/ threshold value is used here. BasePathSize in CastExpr might
234aaf1dcaSRoman Lebedev // not fit it, so we are testing that we do fit it.
244aaf1dcaSRoman Lebedev // If -ftemplate-depth= is provided, larger values (4096 and up) cause crashes
254aaf1dcaSRoman Lebedev // elsewhere.
264aaf1dcaSRoman Lebedev d<g, g::h, (1U << 10U) - 2U> f;
274aaf1dcaSRoman Lebedev };
j() const284aaf1dcaSRoman Lebedev void i::j() const {
294aaf1dcaSRoman Lebedev const void *k{f.f};
304aaf1dcaSRoman Lebedev (void)k;
314aaf1dcaSRoman Lebedev }
32