summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2016-01-25 10:34:06 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2016-01-25 10:34:06 +0000
commit54f81ed325f05b46f5bc0b63524d72103437b795 (patch)
tree89e2ee44d5a38ab794778a0308bf5201ad5b5c70 /clang
parent65b85382f60991929b4abca37bce8e7c1d1df0fb (diff)
downloadbcm5719-llvm-54f81ed325f05b46f5bc0b63524d72103437b795.tar.gz
bcm5719-llvm-54f81ed325f05b46f5bc0b63524d72103437b795.zip
Fix printing of types in initializers with suppressed tags.
Tag and specifier printing can be suppressed in Decl::printGroup, but these suppressions leak into the initializers. Thus int *x = ((void *)0), *y = ((void *)0); gets printed as int *x = ((void *)0), *y = ((*)0); And struct { struct Z z; } z = {(struct Z){}}; gets printed as struct { struct Z z; } z = {(){}}; The stops the suppressions from leaking into the initializers. Patch by Nick Sumner! Differential Revision: http://reviews.llvm.org/D16438 llvm-svn: 258679
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/DeclPrinter.cpp5
-rw-r--r--clang/test/Sema/ast-print.c10
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){}};
+}
OpenPOWER on IntegriCloud