| 1 |
/* Test that thread-local declarations are not considered tentative definitions |
| 2 |
in C23. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 5 |
|
| 6 |
thread_local int a; /* { dg-message "previous" } */ |
| 7 |
thread_local int a; /* { dg-error "redefinition" } */ |
| 8 |
|
| 9 |
static thread_local int b; /* { dg-message "previous" } */ |
| 10 |
static thread_local int b; /* { dg-error "redefinition" } */ |
| 11 |
|
| 12 |
thread_local int c; /* { dg-message "previous" } */ |
| 13 |
thread_local int c = 1; /* { dg-error "redefinition" } */ |
| 14 |
|
| 15 |
static thread_local int d; /* { dg-message "previous" } */ |
| 16 |
static thread_local int d = 1; /* { dg-error "redefinition" } */ |
| 17 |
|
| 18 |
thread_local int e = 1; /* { dg-message "previous" } */ |
| 19 |
thread_local int e; /* { dg-error "redefinition" } */ |
| 20 |
|
| 21 |
static thread_local int f = 1; /* { dg-message "previous" } */ |
| 22 |
static thread_local int f; /* { dg-error "redefinition" } */ |
| 23 |
|
| 24 |
/* Not being a tentative definition means that incomplete arrays are an error |
| 25 |
rather than defaulting to size 1. */ |
| 26 |
thread_local int g[]; /* { dg-error "storage size" } */ |
| 27 |
static thread_local int h[]; /* { dg-error "array size missing" } */ |
| 28 |
extern thread_local int i[]; |
| 29 |
|
| 30 |
thread_local int j[] = { 0 }; |
| 31 |
static thread_local int k[] = { 0 }; |
| 32 |
|
| 33 |
thread_local int l; |
| 34 |
extern thread_local int l; |
| 35 |
|
| 36 |
extern thread_local int m; |
| 37 |
thread_local int m; |
| 38 |
|
| 39 |
static thread_local int n; |
| 40 |
extern thread_local int n; |