sberg updated this revision to Diff 224823.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68581/new/

https://reviews.llvm.org/D68581

Files:
  clang/lib/Parse/ParseStmt.cpp
  clang/test/AST/sourceranges.cpp


Index: clang/test/AST/sourceranges.cpp
===================================================================
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -144,3 +144,18 @@
   }
 }
 #endif
+
+// CHECK: NamespaceDecl {{.*}} attributed_decl
+namespace attributed_decl {
+  void cpp11() {
+    // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:34>
+    int __attribute__((unused)) i;
+  }
+
+#if __cplusplus >= 201703L
+  void cpp17() {
+    // CHECK-1Z: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:27>
+    [[maybe_unused]] int i;
+  }
+#endif
+}
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
@@ -144,3 +144,18 @@
   }
 }
 #endif
+
+// CHECK: NamespaceDecl {{.*}} attributed_decl
+namespace attributed_decl {
+  void cpp11() {
+    // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:34>
+    int __attribute__((unused)) i;
+  }
+
+#if __cplusplus >= 201703L
+  void cpp17() {
+    // CHECK-1Z: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:27>
+    [[maybe_unused]] int i;
+  }
+#endif
+}
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);
     }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to