summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-02-22 11:25:29 +0000
committerHans Wennborg <hans@hanshq.net>2018-02-22 11:25:29 +0000
commita0152d8269896483086fc02b1f3b12c25afb8085 (patch)
tree144555ca8f359acb2304b5a451c2f445617766b7
parent36040b6238195161579408da4ba4dd0c344f6607 (diff)
Merging r324308:
------------------------------------------------------------------------ r324308 | rtrieu | 2018-02-06 03:58:21 +0100 (Tue, 06 Feb 2018) | 4 lines Fix crash on invalid. Don't call a method when the pointer is null. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325766 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp3
-rw-r--r--test/SemaCXX/lambda-expressions.cpp15
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 7e01b058ab..a6e43765e1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -14926,7 +14926,8 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc,
if (RefersToEnclosingScope) {
LambdaScopeInfo *const LSI =
SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true);
- if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext())) {
+ if (LSI && (!LSI->CallOperator ||
+ !LSI->CallOperator->Encloses(Var->getDeclContext()))) {
// If a variable could potentially be odr-used, defer marking it so
// until we finish analyzing the full expression for any
// lvalue-to-rvalue
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp
index de77467b6d..4565345fc6 100644
--- a/test/SemaCXX/lambda-expressions.cpp
+++ b/test/SemaCXX/lambda-expressions.cpp
@@ -608,3 +608,18 @@ namespace ConversionOperatorDoesNotHaveDeducedReturnType {
// This used to crash in return type deduction for the conversion opreator.
struct A { int n; void f() { +[](decltype(n)) {}; } };
}
+
+namespace TypoCorrection {
+template <typename T> struct X {};
+// expected-note@-1 {{template parameter is declared here}}
+
+template <typename T>
+void Run(const int& points) {
+// expected-note@-1 {{'points' declared here}}
+ auto outer_lambda = []() {
+ auto inner_lambda = [](const X<Points>&) {};
+ // expected-error@-1 {{use of undeclared identifier 'Points'; did you mean 'points'?}}
+ // expected-error@-2 {{template argument for template type parameter must be a type}}
+ };
+}
+}