Remove C++11 keywords "override", "final" and "constexpr"

This commit is contained in:
PKEuS 2012-11-09 19:53:10 +01:00
parent ce961578c2
commit 58fe7105f4
2 changed files with 10 additions and 8 deletions

View File

@ -8404,21 +8404,20 @@ void Tokenizer::simplifyAttribute()
}
}
// Remove "volatile", "inline", "register", and "restrict"
// Remove "volatile", "inline", "register", "restrict", "override", "final" and "constexpr"
// "restrict" keyword
// - New to 1999 ANSI/ISO C standard
// - Not in C++ standard yet
void Tokenizer::simplifyKeyword()
{
const char *pattern;
std::string pattern = "volatile|inline|__inline|__forceinline|register|__restrict|__restrict__";
if (_settings->standards.c >= Standards::C99)
pattern = "volatile|inline|__inline|__forceinline|register|restrict|__restrict|__restrict__";
else
pattern = "volatile|inline|__inline|__forceinline|register|__restrict|__restrict__";
pattern += "|restrict";
if (_settings->standards.cpp >= Standards::CPP11)
pattern += "|constexpr|override|final";
for (Token *tok = list.front(); tok; tok = tok->next()) {
while (Token::Match(tok, pattern)) {
while (Token::Match(tok, pattern.c_str())) {
tok->deleteThis();
}
}

View File

@ -5478,7 +5478,7 @@ private:
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
checkSimplifyTypedef("typedef constexpr\n");
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef82() { // ticket #2403
@ -7671,6 +7671,9 @@ private:
ASSERT_EQUALS("int foo ( ) { }", tok("inline int foo ( ) { }", true));
ASSERT_EQUALS("int foo ( ) { }", tok("__inline int foo ( ) { }", true));
ASSERT_EQUALS("int foo ( ) { }", tok("__forceinline int foo ( ) { }", true));
ASSERT_EQUALS("int foo ( ) { }", tok("constexpr int foo() { }", true));
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() override ; };", true));
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() final ; };", true));
ASSERT_EQUALS("if ( a ) { }", tok("if ( likely ( a ) ) { }", true));
ASSERT_EQUALS("if ( a ) { }", tok("if ( unlikely ( a ) ) { }", true));
ASSERT_EQUALS("int * p ;", tok("int * __restrict p;", "test.c"));