* Fix #9338 (Regression: Syntax error on valid C++) * fix cppcheck warning
This commit is contained in:
parent
d20b1b2525
commit
639c29eb5c
|
@ -3494,6 +3494,14 @@ void TemplateSimplifier::simplifyTemplates(
|
|||
const std::time_t maxtime,
|
||||
bool &codeWithTemplates)
|
||||
{
|
||||
// convert "sizeof ..." to "sizeof..."
|
||||
for (Token *tok = mTokenList.front(); tok; tok = tok->next()) {
|
||||
if (Token::simpleMatch(tok, "sizeof ...")) {
|
||||
tok->str("sizeof...");
|
||||
tok->deleteNext();
|
||||
}
|
||||
}
|
||||
|
||||
// split ">>" into "> >"
|
||||
fixAngleBrackets();
|
||||
|
||||
|
|
|
@ -179,6 +179,7 @@ private:
|
|||
TEST_CASE(template139);
|
||||
TEST_CASE(template140);
|
||||
TEST_CASE(template141); // #9337
|
||||
TEST_CASE(template142); // #9338
|
||||
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
TEST_CASE(template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
|
||||
|
@ -3441,6 +3442,20 @@ private:
|
|||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
|
||||
void template142() { // #9338
|
||||
const char code[] = "template <typename...> struct a;\n"
|
||||
"template <typename b, typename c, typename... d> struct a<b c::*, d...> {\n"
|
||||
" using typename b ::e;\n"
|
||||
" static_assert(e::f ? sizeof...(d) : sizeof...(d), \"\");\n"
|
||||
"};";
|
||||
const char exp[] = "template < typename ... > struct a ; "
|
||||
"template < typename b , typename c , typename ... d > struct a < b c :: * , d ... > { "
|
||||
"using b :: e ; "
|
||||
"static_assert ( e :: f ? sizeof... ( d ) : sizeof... ( d ) , \"\" ) ; "
|
||||
"} ;";
|
||||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
|
||||
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
const char code[] = "template <typename T> struct C {};\n"
|
||||
"template <typename T> struct S {a};\n"
|
||||
|
|
Loading…
Reference in New Issue