aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c2x-complit-3.c
blob: c672525ba6f608179dfa1abd551c4d0cfa4789af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Test C2x storage class specifiers in compound literals.  Thread-local
   cases, compilation tests.  */
/* { dg-do compile } */
/* { dg-options "-std=c2x -pedantic-errors" } */
/* { dg-require-effective-target tls } */

#include <stddef.h>

/* thread_local is OK at file scope, although of limited use since the
   thread-local object and its address are not constant expressions.  */
size_t st = sizeof (thread_local int) { 1 };
size_t sst = sizeof (static thread_local int) { 1 };

int *
f ()
{
  return &(static thread_local int) { 2 };
}

int *
g ()
{
  return &(thread_local static int) { 3 };
}