Fixed #4947 (Doesn't allow any ordering of int modifiers)

This commit is contained in:
Robert Reif 2013-08-09 23:13:04 +02:00 committed by Daniel Marjamäki
parent 4c7e92f67b
commit b940d0adc6
2 changed files with 61 additions and 3 deletions

View File

@ -5565,18 +5565,41 @@ void Tokenizer::simplifyStdType()
else if (tok->str() == "__int64") {
tok->str("long");
tok->isLong(true);
} else if (tok->str() == "int") {
if (tok->strAt(1) == "long") {
tok->str("long");
tok->deleteNext();
}
if (tok->strAt(1) == "long") {
tok->isLong(true);
tok->deleteNext();
}
if (tok->strAt(1) == "unsigned") {
tok->isUnsigned(true);
tok->deleteNext();
if (tok->strAt(1) == "long")
tok->deleteNext();
}
} else if (tok->str() == "long") {
if (tok->strAt(1) == "long") {
tok->isLong(true);
tok->deleteNext();
}
if (tok->strAt(1) == "int")
if (tok->strAt(1) == "int") {
tok->deleteNext();
else if (tok->strAt(1) == "double") {
if (tok->strAt(1) == "unsigned") {
tok->isUnsigned(true);
tok->deleteNext();
}
} else if (tok->strAt(1) == "double") {
tok->str("double");
tok->isLong(true);
tok->deleteNext();
} else if (tok->strAt(1) == "unsigned") {
tok->isUnsigned(true);
tok->deleteNext();
if (tok->strAt(1) == "int")
tok->deleteNext();
}
} else if (tok->str() == "short") {
if (tok->strAt(1) == "int")

View File

@ -386,6 +386,8 @@ private:
TEST_CASE(unsigned2);
TEST_CASE(unsigned3); // template arguments
TEST_CASE(simplifyStdType); // #4947
TEST_CASE(createLinks);
TEST_CASE(signed1);
@ -6138,6 +6140,39 @@ private:
}
}
void simplifyStdType() { // #4947
{
const char code[] = "long long unsigned int x;";
const char expected[] = "unsigned long long x ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
{
const char code[] = "long long int unsigned x;";
const char expected[] = "unsigned long long x ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
{
const char code[] = "unsigned long long int x;";
const char expected[] = "unsigned long long x ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
{
const char code[] = "unsigned int long long x;";
const char expected[] = "unsigned long long x ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
{
const char code[] = "int unsigned long long x;";
const char expected[] = "unsigned long long x ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
{
const char code[] = "int long long unsigned x;";
const char expected[] = "unsigned long long x ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
}
void createLinks() {
{
const char code[] = "class A{\n"