libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / c23-complit-3.c
blob310c142ab27dcd0a279702ef2d53c15caf4b70d7
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 } */
7 #include <stddef.h>
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 };
14 int *
15 f ()
17 return &(static thread_local int) { 2 };
20 int *
21 g ()
23 return &(thread_local static int) { 3 };