Remove "auto" keyword (storage class specifier) from C++03 and C code (#4990).

This commit is contained in:
PKEuS 2014-09-02 11:21:47 +02:00
parent 2d608890a5
commit 3e65cb446e
2 changed files with 9 additions and 0 deletions

View File

@ -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") {

View File

@ -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() {