view gcc/testsuite/g++.dg/tls/thread_local-order1.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { dg-do run { target c++11 } }
// { dg-add-options tls }
// { dg-require-effective-target tls_runtime }
// { dg-require-cxa-atexit "" }

extern "C" void abort();
extern "C" int printf (const char *, ...);
#define printf(...)

int c;
struct A {
  int i;
  A(int i): i(i) { printf ("A(%d)\n", i); if (i != c++) abort (); }
  ~A() { printf("~A(%d)\n", i); if (i != --c) abort(); }
};

A a0(0);
thread_local A a1(1);
thread_local A a2(2);
A* ap = &a1;

int main()
{
  if (c != 3) abort();
}