Skip to content

Commit

Permalink
Fixed ticket #3712 (false positive: syntax error on valid C code ( K&…
Browse files Browse the repository at this point in the history
…R function style ))
  • Loading branch information
Edoardo Prezioso committed Apr 12, 2012
1 parent 7be01da commit 51789d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/tokenize.cpp
Expand Up @@ -2041,6 +2041,9 @@ bool Tokenizer::tokenize(std::istream &code,
}
}

// Remove "volatile", "inline", "register", and "restrict"
simplifyKeyword();

// Convert K&R function declarations to modern C
simplifyVarDecl(true);
if (!simplifyFunctionParameters())
Expand Down Expand Up @@ -2097,9 +2100,6 @@ bool Tokenizer::tokenize(std::istream &code,
// remove Borland stuff..
simplifyBorland();

// Remove "volatile", "inline", "register", and "restrict"
simplifyKeyword();

// Remove __builtin_expect, likely and unlikely
simplifyBuiltinExpect();

Expand Down
9 changes: 9 additions & 0 deletions test/testtokenize.cpp
Expand Up @@ -4787,6 +4787,15 @@ class TestTokenizer : public TestFixture {
"{\n"
"}", tokenizeAndStringify(code));
}
{
const char code[] = "void f(a, b) register char *a, *b;\n"
"{\n"
"}\n";

ASSERT_EQUALS("void f ( char * a , char * b )\n"
"{\n"
"}", tokenizeAndStringify(code));
}
}

void vardecl20() {
Expand Down

0 comments on commit 51789d8

Please sign in to comment.