diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 32f885eb2..d13e9034b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9765,9 +9765,11 @@ void Tokenizer::simplifyKeyword() Token::createMutualLinks(braceStart, braceEnd); } - // 3) thread_local + // 3) thread_local -> static + // on single thread thread_local has the effect of static else if (tok->str() == "thread_local") { - tok->deleteThis(); + tok->originalName(tok->str()); + tok->str("static"); } } } diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index c54966b23..6319b1543 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -882,6 +882,13 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + check("std::vector &foo()\n" + "{\n" + " thread_local std::vector v;\n" + " return v;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + check("std::string hello()\n" "{\n" " return \"hello\";\n" diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 0c3441da9..40463057c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4132,7 +4132,7 @@ private: // Ticket #8679 const char code[] = "thread_local void *thread_local_var; " "__thread void *thread_local_var_2;"; - ASSERT_EQUALS("void * thread_local_var ; " + ASSERT_EQUALS("static void * thread_local_var ; " "void * thread_local_var_2 ;", tokenizeAndStringify(code)); } }