diff options
author | dim <dim@FreeBSD.org> | 2017-12-19 11:39:05 +0000 |
---|---|---|
committer | Luiz Souza <luiz@netgate.com> | 2018-02-21 15:18:26 -0300 |
commit | 3a77932294f30029276b6f6d60a05eb03e423c8a (patch) | |
tree | eb7db1c73eeebd7b0e4a57bcc1819c39ddc8c946 | |
parent | bbea8b5633c721444831e921e67ca7e07a2cdfae (diff) | |
download | FreeBSD-src-3a77932294f30029276b6f6d60a05eb03e423c8a.zip FreeBSD-src-3a77932294f30029276b6f6d60a05eb03e423c8a.tar.gz |
MFC r326776:
Pull in r320396 from upstream clang trunk (by Malcolm Parsons):
[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
This fixes a segfault when building recent audio/zynaddsubfx port
versions.
Reported by: hps
(cherry picked from commit d9829aec9cfd6d34e3993203c495522ca778623c)
-rw-r--r-- | contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h | 1 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Sema/SemaLambda.cpp | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h b/contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h index 4251fa6..215f30a 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h @@ -560,6 +560,7 @@ public: void markUsed(bool IsODRUse) { (IsODRUse ? ODRUsed : NonODRUsed) = true; } VarDecl *getVariable() const { + assert(isVariableCapture()); return VarAndNestedAndThis.getPointer(); } diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaLambda.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaLambda.cpp index 46f2ba3..b0b7e64 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaLambda.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaLambda.cpp @@ -1469,6 +1469,9 @@ void Sema::DiagnoseUnusedLambdaCapture(const LambdaScopeInfo::Capture &From) { if (CaptureHasSideEffects(From)) return; + if (From.isVLATypeCapture()) + return; + auto diag = Diag(From.getLocation(), diag::warn_unused_lambda_capture); if (From.isThisCapture()) diag << "'this'"; |