parent
dc1c60f97f
commit
03603c85cf
|
@ -5009,7 +5009,8 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
|
|||
else if (type->isUnsigned())
|
||||
valuetype->sign = ValueType::Sign::UNSIGNED;
|
||||
if (valuetype->type == ValueType::Type::UNKNOWN_TYPE &&
|
||||
type->type() && type->type()->isTypeAlias() && type->type()->typeStart)
|
||||
type->type() && type->type()->isTypeAlias() && type->type()->typeStart &&
|
||||
type->type()->typeStart->str() != type->str())
|
||||
parsedecl(type->type()->typeStart, valuetype, defaultSignedness, settings);
|
||||
else if (type->str() == "const")
|
||||
valuetype->constness |= (1 << (valuetype->pointer - pointer0));
|
||||
|
|
|
@ -70,6 +70,8 @@ private:
|
|||
TEST_CASE(testAstType); // #7014
|
||||
TEST_CASE(testPrintf0WithSuffix); // ticket #7069
|
||||
TEST_CASE(testReturnValueTypeStdLib);
|
||||
|
||||
TEST_CASE(testPrintfTypeAlias1);
|
||||
}
|
||||
|
||||
void check(const char* code, bool inconclusive = false, bool portability = false, Settings::PlatformType platform = Settings::Unspecified) {
|
||||
|
@ -4666,6 +4668,32 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void testPrintfTypeAlias1() {
|
||||
check("using INT = int;\n\n"
|
||||
"using PINT = INT *;\n"
|
||||
"using PCINT = const PINT;\n"
|
||||
"INT i;\n"
|
||||
"PINT pi;\n"
|
||||
"PCINT pci;"
|
||||
"void foo() {\n"
|
||||
" printf(\"%d %p %p\", i, pi, pci);\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("using INT = int;\n\n"
|
||||
"using PINT = INT *;\n"
|
||||
"using PCINT = const PINT;\n"
|
||||
"INT i;\n"
|
||||
"PINT pi;\n"
|
||||
"PCINT pci;"
|
||||
"void foo() {\n"
|
||||
" printf(\"%f %f %f\", i, pi, pci);\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (warning) %f in format string (no. 1) requires 'double' but the argument type is 'signed int'.\n"
|
||||
"[test.cpp:8]: (warning) %f in format string (no. 2) requires 'double' but the argument type is 'signed int *'.\n"
|
||||
"[test.cpp:8]: (warning) %f in format string (no. 3) requires 'double' but the argument type is 'const signed int *'.\n", errout.str());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestIO)
|
||||
|
|
|
@ -351,6 +351,7 @@ private:
|
|||
TEST_CASE(unionWithConstructor);
|
||||
|
||||
TEST_CASE(using1);
|
||||
TEST_CASE(using2); // #8331
|
||||
}
|
||||
|
||||
void array() {
|
||||
|
@ -5318,7 +5319,7 @@ private:
|
|||
void using1() {
|
||||
Standards::cppstd_t original_std = settings1.standards.cpp;
|
||||
settings1.standards.cpp = Standards::CPP11;
|
||||
GET_SYMBOL_DB("using INT = int;\n\n"
|
||||
GET_SYMBOL_DB("using INT = int;\n"
|
||||
"using PINT = INT *;\n"
|
||||
"using PCINT = const PINT;\n"
|
||||
"INT i;\n"
|
||||
|
@ -5359,6 +5360,36 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void using2() { // #8331 (segmentation fault)
|
||||
Standards::cppstd_t original_std = settings1.standards.cpp;
|
||||
settings1.standards.cpp = Standards::CPP11;
|
||||
|
||||
{
|
||||
GET_SYMBOL_DB("using pboolean = pboolean;\n"
|
||||
"pboolean b;");
|
||||
const Token *tok = Token::findsimplematch(tokenizer.tokens(), "b ;");
|
||||
|
||||
ASSERT(db && tok && !tok->valueType());
|
||||
}
|
||||
|
||||
{
|
||||
GET_SYMBOL_DB("using pboolean = bool;\n"
|
||||
"using pboolean = pboolean;\n"
|
||||
"pboolean b;");
|
||||
const Token *tok = Token::findsimplematch(tokenizer.tokens(), "b ;");
|
||||
|
||||
ASSERT(db && tok && tok->valueType());
|
||||
if (db && tok && tok->valueType()) {
|
||||
ASSERT_EQUALS(0, tok->valueType()->constness);
|
||||
ASSERT_EQUALS(0, tok->valueType()->pointer);
|
||||
ASSERT_EQUALS(ValueType::UNKNOWN_SIGN, tok->valueType()->sign);
|
||||
ASSERT_EQUALS(ValueType::BOOL, tok->valueType()->type);
|
||||
}
|
||||
}
|
||||
|
||||
settings1.standards.cpp = original_std;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSymbolDatabase)
|
||||
|
|
Loading…
Reference in New Issue