| 1 |
/* Test C23 storage class specifiers in compound literals. Thread-local |
| 2 |
cases, compilation tests. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 5 |
/* { dg-require-effective-target tls } */ |
| 6 |
|
| 7 |
#include <stddef.h> |
| 8 |
|
| 9 |
/* thread_local is OK at file scope, although of limited use since the |
| 10 |
thread-local object and its address are not constant expressions. */ |
| 11 |
size_t st = sizeof (thread_local int) { 1 }; |
| 12 |
size_t sst = sizeof (static thread_local int) { 1 }; |
| 13 |
|
| 14 |
int * |
| 15 |
f () |
| 16 |
{ |
| 17 |
return &(static thread_local int) { 2 }; |
| 18 |
} |
| 19 |
|
| 20 |
int * |
| 21 |
g () |
| 22 |
{ |
| 23 |
return &(thread_local static int) { 3 }; |
| 24 |
} |