AST types: Fix for 'long long' handling

This commit is contained in:
Daniel Marjamäki 2015-10-05 19:20:42 +02:00
parent bc8f1b972e
commit b9036c2ca8
4 changed files with 13 additions and 3 deletions

View File

@ -1374,9 +1374,10 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings,
tempToken->str("int");
else if (valuetype->type == ValueType::LONG)
tempToken->str("long");
else if (valuetype->type == ValueType::LONGLONG)
else if (valuetype->type == ValueType::LONGLONG) {
tempToken->str("long");
else if (valuetype->type == ValueType::FLOAT)
tempToken->isLong(true);
} else if (valuetype->type == ValueType::FLOAT)
tempToken->str("float");
else if (valuetype->type == ValueType::DOUBLE)
tempToken->str("double");

View File

@ -3722,7 +3722,7 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype)
else if (type->str() == "int")
valuetype->type = ValueType::Type::INT;
else if (type->str() == "long")
valuetype->type = ValueType::Type::LONG;
valuetype->type = type->isLong() ? ValueType::Type::LONGLONG : ValueType::Type::LONG;
else if (type->str() == "float")
valuetype->type = ValueType::Type::FLOAT;
else if (type->str() == "double")

View File

@ -3730,6 +3730,12 @@ private:
" printf(\"%c\", \"hello\"[0]);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void test() {\n"
" printf(\"%lld\", (long long)1);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
};

View File

@ -2980,6 +2980,9 @@ private:
// cast..
ASSERT_EQUALS("char", typeOf("a = (char)32;", "("));
ASSERT_EQUALS("long", typeOf("a = (long)32;", "("));
ASSERT_EQUALS("long", typeOf("a = (long int)32;", "("));
ASSERT_EQUALS("long long", typeOf("a = (long long)32;", "("));
}
};