From c2eec6c4beee3e02546e34b692028404cd8b38b3 Mon Sep 17 00:00:00 2001 From: Virgile Prevosto <virgile.prevosto@m4x.org> Date: Tue, 26 May 2020 16:13:03 +0200 Subject: [PATCH] [parsing] accurate info of original kw (__thread or _Thread_local) for THREAD --- src/kernel_internals/parsing/clexer.mll | 2 +- src/kernel_internals/parsing/cparser.mly | 11 +++++------ tests/syntax/oracle/thread.res.oracle | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/kernel_internals/parsing/clexer.mll b/src/kernel_internals/parsing/clexer.mll index 765ee47bd84..603bab87c56 100644 --- a/src/kernel_internals/parsing/clexer.mll +++ b/src/kernel_internals/parsing/clexer.mll @@ -208,7 +208,7 @@ let init_lexicon _ = ("__builtin_offsetof", fun loc -> BUILTIN_OFFSETOF loc); ("_Thread_local", fun loc -> - if Kernel.C11.get () then THREAD loc + if Kernel.C11.get () then THREAD_LOCAL loc else begin Kernel.( warning diff --git a/src/kernel_internals/parsing/cparser.mly b/src/kernel_internals/parsing/cparser.mly index c77c2f75cdb..95a4c0e88dd 100644 --- a/src/kernel_internals/parsing/cparser.mly +++ b/src/kernel_internals/parsing/cparser.mly @@ -334,7 +334,7 @@ let in_ghost_block ?(battrs=[]) l = %token<Cabs.cabsloc> ENUM STRUCT TYPEDEF UNION %token<Cabs.cabsloc> SIGNED UNSIGNED LONG SHORT %token<Cabs.cabsloc> VOLATILE EXTERN STATIC CONST RESTRICT AUTO REGISTER -%token<Cabs.cabsloc> THREAD +%token<Cabs.cabsloc> THREAD THREAD_LOCAL %token<Cabs.cabsloc> GHOST %token<Cabs.cabsloc> SIZEOF ALIGNOF @@ -1510,11 +1510,10 @@ attribute_nocv: | DECLSPEC paren_attr_list_ne { ("__declspec", $2), $1 } | MSATTR { (fst $1, []), snd $1 } /* ISO 6.7.3 */ -| THREAD { ("__thread", - if Kernel.C11.get() then [make_expr (VARIABLE "c11")] - else [] - ), $1 } - +| THREAD { ("__thread", []), $1 } +| THREAD_LOCAL { ("__thread", + [make_expr (VARIABLE "c11")]), + $1 } ; attribute_nocv_list: diff --git a/tests/syntax/oracle/thread.res.oracle b/tests/syntax/oracle/thread.res.oracle index 1d65cdc4dc2..8d43c550e32 100644 --- a/tests/syntax/oracle/thread.res.oracle +++ b/tests/syntax/oracle/thread.res.oracle @@ -1,8 +1,8 @@ [kernel] Parsing tests/syntax/thread.i (no preprocessing) /* Generated by Frama-C */ - _Thread_local int a; -static _Thread_local int b; -extern _Thread_local int c; + __thread int a; +static __thread int b; +extern __thread int c; _Thread_local int d; int main(void) -- GitLab