fix Issue 23715 - ImportC: No rejection of _Thread_local variables declared at function scope without 'static' as per C11 6.2.4-5 (#15094)

This commit is contained in:
Walter Bright 2023-04-10 16:53:38 -07:00 committed by GitHub
parent b571a1a118
commit 5cd6f80d06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View file

@ -2544,6 +2544,12 @@ final class CParser(AST) : Parser!AST
error("`inline` and `_Noreturn` function specifiers not allowed for `_Thread_local`");
scw &= ~scwx;
}
if (level == LVL.local &&
scw & (SCW.x_Thread_local) && !(scw & (SCW.xstatic | SCW.xextern)))
{
error("`_Thread_local` in block scope must be accompanied with `static` or `extern`"); // C11 6.7.1-3
scw &= ~scwx;
}
if (level & (LVL.parameter | LVL.prototype) &&
scw & ~SCW.xregister)
{

View file

@ -277,7 +277,7 @@ void test2()
typedef int TI;
//extern int ei;
static int si;
_Thread_local int tli;
static _Thread_local int tli;
int __declspec(thread) tlj;
auto int ai;
register int reg;

View file

@ -0,0 +1,12 @@
/* TEST_OUTPUT:
---
fail_compilation/test23715.i(11): Error: `_Thread_local` in block scope must be accompanied with `static` or `extern`
---
*/
// https://issues.dlang.org/show_bug.cgi?id=23715
void test2()
{
_Thread_local int tli;
}