Skip to content

Commit caf1bd5

Browse files
committed
C: add "__thread" GCC extension keyword
The parser records it to "properties:" field as "thread_local" property. Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 29bcaad commit caf1bd5

File tree

6 files changed

+18
-0
lines changed

6 files changed

+18
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--sort=no
2+
--kinds-c=*-{parameter}
3+
--fields=+x
4+
--fields-c=+{properties}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
i input.c /^__thread int i;$/;" v typeref:typename:int properties:thread_local
2+
s input.c /^extern __thread struct state s;$/;" x typeref:struct:state properties:extern,thread_local
3+
p input.c /^static __thread char *p;$/;" v typeref:typename:char * file: properties:static,thread_local
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Taken from https://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Thread-Local.html#Thread-Local */
2+
__thread int i;
3+
extern __thread struct state s;
4+
static __thread char *p;

parsers/cxx/cxx_keyword.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ static CXXKeywordDescriptor g_aCXXKeywordTable[] = {
136136
CXXLanguageCPP,
137137
0
138138
},
139+
{
140+
"__thread",
141+
CXXLanguageC | CXXLanguageCPP,
142+
CXXKeywordMayAppearInVariableDeclaration | CXXKeywordExcludeFromTypeNames,
143+
},
139144
{
140145
"alignas",
141146
CXXLanguageCPP,

parsers/cxx/cxx_keyword.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef enum _CXXKeyword
3333
CXXKeyword__SHARED__, // CUDA
3434
CXXKeyword__STDCALL, // Microsoft C/C++
3535
CXXKeyword__THISCALL, // Microsoft C/C++
36+
CXXKeyword__THREAD, // GCC (https://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Thread-Local.html#Thread-Local)
3637
CXXKeywordALIGNAS, // (since C++11)
3738
CXXKeywordALIGNOF, // (since C++11)
3839
//CXXKeywordAND,

parsers/cxx/cxx_parser_block.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ static bool cxxParserParseBlockInternal(bool bExpectClosingBracket)
647647
g_cxx.uKeywordState |= CXXParserKeywordStateSeenConstinit;
648648
break;
649649
case CXXKeywordTHREAD_LOCAL:
650+
case CXXKeyword__THREAD:
650651
g_cxx.uKeywordState |= CXXParserKeywordStateSeenThreadLocal;
651652
break;
652653

0 commit comments

Comments
 (0)