From 6365c9138e26add7d5ee99b74ad4edd309024c3c Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 24 Feb 2012 22:12:32 +0000 Subject: 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. llvm-svn: 151399 --- clang/test/SemaCXX/lambda-expressions.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'clang/test/SemaCXX/lambda-expressions.cpp') diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp index 1358d9e2a39..e1b0f49cc8d 100644 --- a/clang/test/SemaCXX/lambda-expressions.cpp +++ b/clang/test/SemaCXX/lambda-expressions.cpp @@ -101,3 +101,30 @@ namespace PR12031 { 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? + } (); + } +} -- cgit v1.2.3