diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -891,6 +891,7 @@ D->getIdentifier()) ? D->getIdentifier()->deuglifiedName() : D->getName()); + prettyPrintAttributes(D); Expr *Init = D->getInit(); if (!Policy.SuppressInitializers && Init) { bool ImplicitInit = false; @@ -919,7 +920,6 @@ Out << ")"; } } - prettyPrintAttributes(D); } void DeclPrinter::VisitParmVarDecl(ParmVarDecl *D) { diff --git a/clang/test/AST/ast-print-attr.c b/clang/test/AST/ast-print-attr.c --- a/clang/test/AST/ast-print-attr.c +++ b/clang/test/AST/ast-print-attr.c @@ -32,3 +32,9 @@ // CHECK: void fun_holds(int *a) __attribute__((ownership_holds(fun_holds, 1))); void fun_holds(int *a) __attribute__((ownership_holds(fun_holds, 1))); + +// CHECK: int fun_var_unused() { +// CHECK-NEXT: int x __attribute__((unused)) = 0; +// CHECK-NEXT: return x; +// CHECK-NEXT: } +int fun_var_unused() { int x __attribute__((unused)) = 0; return x; } diff --git a/clang/test/AST/ast-print-pragmas.cpp b/clang/test/AST/ast-print-pragmas.cpp --- a/clang/test/AST/ast-print-pragmas.cpp +++ b/clang/test/AST/ast-print-pragmas.cpp @@ -92,8 +92,9 @@ #ifdef MS_EXT #pragma init_seg(compiler) +/* FIXME: Trying to compile the output source results in compilation error. */ // MS-EXT: #pragma init_seg (.CRT$XCC){{$}} -// MS-EXT-NEXT: int x = 3 __declspec(thread); +// MS-EXT-NEXT: int x __declspec(thread) = 3; int __declspec(thread) x = 3; #endif //MS_EXT