Pretty-print a ParenListExpr in a variable initializer correctly. Patch by Grzegorz Jablonski.

llvm-svn: 166311
This commit is contained in:
Eli Friedman 2012-10-19 20:36:44 +00:00
parent 46d8fc9d6b
commit 92125c474a
2 changed files with 10 additions and 2 deletions

View File

@ -629,13 +629,13 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
ImplicitInit = D->getInitStyle() == VarDecl::CallInit &&
Construct->getNumArgs() == 0 && !Construct->isListInitialization();
if (!ImplicitInit) {
if (D->getInitStyle() == VarDecl::CallInit)
if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
Out << "(";
else if (D->getInitStyle() == VarDecl::CInit) {
Out << " = ";
}
Init->printPretty(Out, 0, Policy, Indentation);
if (D->getInitStyle() == VarDecl::CallInit)
if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
Out << ")";
}
}

View File

@ -52,3 +52,11 @@ void test6() {
unsigned int y = 0;
test6fn((int&)y);
}
// CHECK: S s( 1, 2 );
template <class S> void test7()
{
S s( 1,2 );
}