https://github.com/ecnelises created https://github.com/llvm/llvm-project/pull/72230
Fixes #72198 >From 0b74141dec486989f75f4c361e8b950b869f7a1e Mon Sep 17 00:00:00 2001 From: Qiu Chaofan <qiuco...@cn.ibm.com> Date: Tue, 14 Nov 2023 16:20:42 +0800 Subject: [PATCH] [Sema] Check nullness of captured type before use --- clang/lib/Sema/SemaExpr.cpp | 2 ++ clang/test/SemaCXX/lambda-invalid-capture.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5b0c4439fd1710c..cb7383ea8790f67 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -19773,6 +19773,8 @@ bool Sema::tryCaptureVariable( // declcontext can either capture the variable or have already captured // the variable. CaptureType = Var->getType(); + if (CaptureType.isNull()) + return true; DeclRefType = CaptureType.getNonReferenceType(); bool Nested = false; bool Explicit = (Kind != TryCapture_Implicit); diff --git a/clang/test/SemaCXX/lambda-invalid-capture.cpp b/clang/test/SemaCXX/lambda-invalid-capture.cpp index 236753871d7018b..b77a844cfbbda50 100644 --- a/clang/test/SemaCXX/lambda-invalid-capture.cpp +++ b/clang/test/SemaCXX/lambda-invalid-capture.cpp @@ -23,3 +23,9 @@ int pr43080(int i) { // expected-note {{declared here}} i; // expected-error {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}} }(); } + +void pr72198() { + int [_, b] = {0, 0}; // expected-error{{decomposition declaration cannot be declared with type 'int'; declared type must be 'auto' or reference to 'auto'}} \ + expected-error{{excess elements in scalar initializer}} + [b]{}; // expected-warning{{expression result unused}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits