diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index cd51d749c..c11bce872 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9374,6 +9374,13 @@ void Tokenizer::simplifyKeyword() tok->deleteThis(); } + if (isC() || _settings->standards.cpp == Standards::CPP03) { + for (Token *tok = list.front(); tok; tok = tok->next()) { + if (tok->str() == "auto") + tok->deleteThis(); + } + } + if (_settings->standards.c >= Standards::C99) { for (Token *tok = list.front(); tok; tok = tok->next()) { while (tok->str() == "restrict") { diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 6eef6f062..990e5e722 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -7659,6 +7659,8 @@ private: // don't remove struct members: ASSERT_EQUALS("a = b . _inline ;", tok("a = b._inline;", true)); + ASSERT_EQUALS("int i ; i = 0 ;", tok("auto int i = 0;", "test.c")); + ASSERT_EQUALS("auto i ; i = 0 ;", tok("auto i = 0;", "test.cpp")); } void simplifyCallingConvention() {