summary refs log tree commit diff stats
path: root/tests/misc/mtlsemulation.h
blob: 992977acd81fd09810c9f79e09a6bbf47059e06e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>

struct Foo1 {
  /*
  uncommenting would give:
  error: initializer for thread-local variable must be a constant expression
  N_LIB_PRIVATE NIM_THREADVAR Foo1 g1__9brEZhPEldbVrNpdRGmWESA;
  */
  // Foo1() noexcept { }

  /*
  uncommenting would give:
  error: type of thread-local variable has non-trivial destruction
  */
  // ~Foo1() { }
  int x;
};

struct Foo2 {
  Foo2() noexcept { }
  ~Foo2() { }
  int x;
};

static int ctorCalls = 0;
static int dtorCalls = 0;

struct Foo3 {
  Foo3() noexcept {
    ctorCalls = ctorCalls + 1;
    x = 10;
  }
  ~Foo3() {
    dtorCalls = dtorCalls + 1;
  }
  int x;
};