]> granicus.if.org Git - clang/commitdiff
Pretty-print a ParenListExpr in a variable initializer correctly. Patch by Grzegorz...
authorEli Friedman <eli.friedman@gmail.com>
Fri, 19 Oct 2012 20:36:44 +0000 (20:36 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 19 Oct 2012 20:36:44 +0000 (20:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166311 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclPrinter.cpp
test/SemaCXX/ast-print.cpp

index 45280df812fb816284d4b496e77bd755d11e2810..386ad66c9917af7bae122475455e7758ae0b17d2 100644 (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 << ")";
     }
   }
index 5e89c8b548847d38c7f7198c01b7e2426909fb51..e0c154a0ecbed89b540c84be852f7301db241d8e 100644 (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 );
+}
+