From 3e65cb446e54f426359b8637ef013c0d8c7eb2eb Mon Sep 17 00:00:00 2001 From: PKEuS Date: Tue, 2 Sep 2014 11:21:47 +0200 Subject: [PATCH] Remove "auto" keyword (storage class specifier) from C++03 and C code (#4990). --- lib/tokenize.cpp | 7 +++++++ test/testsimplifytokens.cpp | 2 ++ 2 files changed, 9 insertions(+) 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() {