When checking whether a reference to a variable is an ICE, look at the type of
the declaration, not at the type of the DeclRefExpr, since within a lambda the
DeclRefExpr can be more const than the declaration is.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151399 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp
index 1358d9e..e1b0f49 100644
--- a/test/SemaCXX/lambda-expressions.cpp
+++ b/test/SemaCXX/lambda-expressions.cpp
@@ -101,3 +101,30 @@
f(v, [](){});
}
}
+
+namespace NullPtr {
+ int &f(int *p);
+ char &f(...);
+ void g() {
+ int n = 0;
+ [=] {
+ char &k = f(n); // not a null pointer constant
+ } ();
+
+ const int m = 0;
+ [=] {
+ int &k = f(m); // a null pointer constant
+ } ();
+
+ // FIXME: At least the second of these cases should probably not be
+ // considered to be a null pointer constant.
+ [=] () -> bool {
+ int &k = f(m); // a null pointer constant?
+ return &m == 0; // no, captured!
+ } ();
+
+ [m] {
+ int &k = f(m); // a null pointer constant?
+ } ();
+ }
+}