diff options
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 5 | ||||
-rw-r--r-- | clang/test/Sema/ast-print.c | 10 |
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 5c6002d55c0..6a3e8e2ae1a 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -751,7 +751,10 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { else if (D->getInitStyle() == VarDecl::CInit) { Out << " = "; } - Init->printPretty(Out, nullptr, Policy, Indentation); + PrintingPolicy SubPolicy(Policy); + SubPolicy.SuppressSpecifiers = false; + SubPolicy.SuppressTag = false; + Init->printPretty(Out, nullptr, SubPolicy, Indentation); if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init)) Out << ")"; } diff --git a/clang/test/Sema/ast-print.c b/clang/test/Sema/ast-print.c index b4d76844fef..b0e421410b2 100644 --- a/clang/test/Sema/ast-print.c +++ b/clang/test/Sema/ast-print.c @@ -53,3 +53,13 @@ struct pair_t { // CHECK: struct pair_t p = {a: 3, .b = 4}; struct pair_t p = {a: 3, .b = 4}; + +void initializers() { + // CHECK: int *x = ((void *)0), *y = ((void *)0); + int *x = ((void *)0), *y = ((void *)0); + struct Z{}; + struct { + struct Z z; + // CHECK: } z = {(struct Z){}}; + } z = {(struct Z){}}; +} |