Fixed ...... in template instantiations (similar to constconst from #6604)

This commit is contained in:
PKEuS 2015-04-13 17:02:48 +02:00
parent b0e9805620
commit b6709294a8
2 changed files with 22 additions and 0 deletions

View File

@ -775,6 +775,10 @@ void TemplateSimplifier::expandTemplate(
for (const Token *typetok = typesUsedInTemplateInstantiation[itype];
typetok && (typeindentlevel>0 || !Token::Match(typetok, ",|>"));
typetok = typetok->next()) {
if (Token::simpleMatch(typetok, ". . .")) {
typetok = typetok->tokAt(2);
continue;
}
if (Token::Match(typetok, "%name% <") && templateParameters(typetok->next()) > 0)
++typeindentlevel;
else if (typeindentlevel > 0 && typetok->str() == ">")

View File

@ -963,6 +963,7 @@ private:
}
void template55() { // #6604
// Avoid constconstconst in macro instantiations
ASSERT_EQUALS(
"class AtSmartPtr<T> : public ConstCastHelper < AtSmartPtr<constT> , T > { "
"friend struct ConstCastHelper < AtSmartPtr<constT> , T > ; "
@ -976,6 +977,23 @@ private:
" friend struct ConstCastHelper<AtSmartPtr<const T>, T>;\n"
" AtSmartPtr(const AtSmartPtr<T>& r);\n"
"};"));
// Similar problem can also happen with ...
ASSERT_EQUALS(
"A<int> a ( 0 ) ; struct A<int> { "
"A<int> ( int * p ) { p ; } "
"} ; "
"struct A<int...> { "
"A<int...> ( int * p ) { "
"p ; "
"} } ;",
tok("template <typename... T> struct A\n"
"{\n"
" A(T* p) {\n"
" (A<T...>*)(p);\n"
" }\n"
"};\n"
"A<int> a(0);"));
}
void template_default_parameter() {