nick.sumner created this revision. nick.sumner added reviewers: bkramer, rsmith. nick.sumner added a subscriber: cfe-commits.
Allow nested variable declarations using suppressed tags. This is the logical conclusion of a handful of patches needed to correctly print types in nested declarations and casts: http://reviews.llvm.org/D16352 http://reviews.llvm.org/D16430 http://reviews.llvm.org/D16437 Currently, for the code: enum Foo { FOO = 0 }; struct { enum Foo foo; } anon = {({ enum Foo foo2 = FOO; foo2; })}; The nested declaration of foo2 omits the tagged type name when printed: foo2 = FOO; With this patch, the tagged type name is included: enum Foo foo2 = FOO; http://reviews.llvm.org/D16438 Files: lib/AST/StmtPrinter.cpp test/Sema/ast-print.c Index: test/Sema/ast-print.c =================================================================== --- test/Sema/ast-print.c +++ test/Sema/ast-print.c @@ -71,6 +71,15 @@ int c = 1; c; }); + + enum Foo { FOO = 0 }; + struct { + enum Foo foo; + } anon = {({ +// CHECK: enum Foo foo2 = FOO; + enum Foo foo2 = FOO; + foo2; + })}; } // CHECK: char c = '\x80'; Index: lib/AST/StmtPrinter.cpp =================================================================== --- lib/AST/StmtPrinter.cpp +++ lib/AST/StmtPrinter.cpp @@ -129,6 +129,7 @@ SmallVector<Decl*, 2> Decls(S->decls()); PrintingPolicy SubPolicy(Policy); SubPolicy.SuppressSpecifiers = false; + SubPolicy.SuppressTag = false; Decl::printGroup(Decls.data(), Decls.size(), OS, SubPolicy, IndentLevel); }
Index: test/Sema/ast-print.c =================================================================== --- test/Sema/ast-print.c +++ test/Sema/ast-print.c @@ -71,6 +71,15 @@ int c = 1; c; }); + + enum Foo { FOO = 0 }; + struct { + enum Foo foo; + } anon = {({ +// CHECK: enum Foo foo2 = FOO; + enum Foo foo2 = FOO; + foo2; + })}; } // CHECK: char c = '\x80'; Index: lib/AST/StmtPrinter.cpp =================================================================== --- lib/AST/StmtPrinter.cpp +++ lib/AST/StmtPrinter.cpp @@ -129,6 +129,7 @@ SmallVector<Decl*, 2> Decls(S->decls()); PrintingPolicy SubPolicy(Policy); SubPolicy.SuppressSpecifiers = false; + SubPolicy.SuppressTag = false; Decl::printGroup(Decls.data(), Decls.size(), OS, SubPolicy, IndentLevel); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits