Index: clang/lib/Parse/ParseStmt.cpp =================================================================== --- clang/lib/Parse/ParseStmt.cpp +++ clang/lib/Parse/ParseStmt.cpp @@ -220,6 +220,8 @@ Decl = ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs); } + if (Attrs.Range.getBegin().isValid()) + DeclStart = Attrs.Range.getBegin(); return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd); } Index: clang/test/AST/sourceranges.cpp =================================================================== --- clang/test/AST/sourceranges.cpp +++ clang/test/AST/sourceranges.cpp @@ -143,4 +143,14 @@ new int{0}; } } + +// CHECK-1Z: NamespaceDecl {{.*}} attributed_decl +namespace attributed_decl { + void f() { + // CHECK-1Z: DeclStmt {{.*}} + [[maybe_unused]] int i; + // CHECK-1Z: DeclStmt {{.*}} + int __attribute__((unused)) j; + } +} #endif