1 //===-------------- thread_local_destruction_order.pass.cpp ---------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Darwin TLV finalization routines fail when creating a thread-local variable
10 // in the destructor for another thread-local variable:
11 // http://lists.llvm.org/pipermail/cfe-dev/2016-November/051376.html
13 // UNSUPPORTED: c++98, c++03
14 // UNSUPPORTED: libcxxabi-no-threads
23 explicit OrderChecker(int n
) : n_
{n
} { }
34 class CreatesThreadLocalInDestructor
{
36 ~CreatesThreadLocalInDestructor() {
37 thread_local OrderChecker checker
{ID
};
41 OrderChecker global
{7};
44 static OrderChecker fn_static
{5};
45 thread_local CreatesThreadLocalInDestructor
<2> creates_tl2
;
46 thread_local OrderChecker fn_thread_local
{1};
47 thread_local CreatesThreadLocalInDestructor
<0> creates_tl0
;
51 static OrderChecker fn_static
{6};
53 std::thread
{thread_fn
}.join();
56 thread_local OrderChecker fn_thread_local
{4};
57 thread_local CreatesThreadLocalInDestructor
<3> creates_tl
;