]> granicus.if.org Git - clang/commitdiff
Add -Wuninitialized test for C++11 lambdas.
authorTed Kremenek <kremenek@apple.com>
Thu, 12 Apr 2012 20:03:47 +0000 (20:03 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 12 Apr 2012 20:03:47 +0000 (20:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154608 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaCXX/uninitialized.cpp

index 15c06eb421ee409d1ea3f1603ff8ae0f80ae9d5c..7879e7c7531f0b76a8b5b8e717db096bb56407ed 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -std=c++11 -verify %s
 
 int foo(int x);
 int bar(int* x);
@@ -162,3 +162,8 @@ int pr12325(int params) {
   return x;
 }
 
+// Test lambda expressions with -Wuninitialized
+int test_lambda() {
+  auto f1 = [] (int x, int y) { int z; return x + y + z; }; // expected-warning {{C++11 requires lambda with omitted result type to consist of a single return statement}} expected-warning{{variable 'z' is uninitialized when used here}} expected-note {{initialize the variable 'z' to silence this warning}}
+  return f1(1, 2);
+}