summaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorMalcolm Parsons <malcolm.parsons@gmail.com>2017-12-11 18:00:36 +0000
committerMalcolm Parsons <malcolm.parsons@gmail.com>2017-12-11 18:00:36 +0000
commit84bf555dbe0c7836c8f67eea29a7cc9390b897bf (patch)
treee7c5e83fcf7e078e39a66a7fb43b5d8e69d3b1b1 /test/SemaCXX
parent20a630420df42944fa7676747f31973bf2021783 (diff)
[Sema] Fix crash in unused-lambda-capture warning for VLAs
Summary: Clang was crashing when diagnosing an unused-lambda-capture for a VLA because From.getVariable() is null for the capture of a VLA bound. Warning about the VLA bound capture is not helpful, so only warn for the VLA itself. Fixes: PR35555 Reviewers: aaron.ballman, dim, rsmith Reviewed By: aaron.ballman, dim Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D41016 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/warn-unused-lambda-capture.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-unused-lambda-capture.cpp b/test/SemaCXX/warn-unused-lambda-capture.cpp
index 6ad8e26604..52ec390b0b 100644
--- a/test/SemaCXX/warn-unused-lambda-capture.cpp
+++ b/test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -191,3 +191,12 @@ void test_templated() {
void test_use_template() {
test_templated<int>(); // expected-note{{in instantiation of function template specialization 'test_templated<int>' requested here}}
}
+
+namespace pr35555 {
+int a;
+void b() {
+ int c[a];
+ auto vla_used = [&c] { return c[0]; };
+ auto vla_unused = [&c] {}; // expected-warning{{lambda capture 'c' is not used}}
+}
+} // namespace pr35555