nick.sumner retitled this revision from "Fix printing of nested variable declarations with suppressed tags" to "Fix printing of types in initializers with suppressed tags.". nick.sumner updated the summary for this revision. nick.sumner updated this revision to Diff 45658. nick.sumner added a comment.
Updated to reset tag and specifier suppression precisely when printing initializers. http://reviews.llvm.org/D16438 Files: lib/AST/DeclPrinter.cpp test/Sema/ast-print.c Index: test/Sema/ast-print.c =================================================================== --- test/Sema/ast-print.c +++ test/Sema/ast-print.c @@ -53,3 +53,13 @@ // 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){}}; +} Index: lib/AST/DeclPrinter.cpp =================================================================== --- lib/AST/DeclPrinter.cpp +++ lib/AST/DeclPrinter.cpp @@ -751,7 +751,10 @@ 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 << ")"; }
Index: test/Sema/ast-print.c =================================================================== --- test/Sema/ast-print.c +++ test/Sema/ast-print.c @@ -53,3 +53,13 @@ // 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){}}; +} Index: lib/AST/DeclPrinter.cpp =================================================================== --- lib/AST/DeclPrinter.cpp +++ lib/AST/DeclPrinter.cpp @@ -751,7 +751,10 @@ 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 << ")"; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits