Author: dingfei Date: 2023-07-24T18:32:46+08:00 New Revision: 3cb16f6d2ddd030c35df7ad3eb7985f1947173cb
URL: https://github.com/llvm/llvm-project/commit/3cb16f6d2ddd030c35df7ad3eb7985f1947173cb DIFF: https://github.com/llvm/llvm-project/commit/3cb16f6d2ddd030c35df7ad3eb7985f1947173cb.diff LOG: [Sema][ObjC] Invalidate BlockDecl with invalid ParmVarDecl BlockDecl should be invalidated because of its invalid ParmVarDecl. Fixes #1 of https://github.com/llvm/llvm-project/issues/64005 Differential Revision: https://reviews.llvm.org/D155984 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaExpr.cpp clang/test/AST/ast-dump-recovery.m Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e686e83583919f..5d09c454dea290 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -674,6 +674,8 @@ Bug Fixes in This Version value exprs is invalid. Propagating the error info up by replacing BlockExpr with a RecoveryExpr. This fixes: (`#63863 <https://github.com/llvm/llvm-project/issues/63863>_`) +- Invalidate BlockDecl with invalid ParmVarDecl + (`#64005 <https://github.com/llvm/llvm-project/issues/64005>_`) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3c9d0efca8a1ee..716383412cc58c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -16959,6 +16959,9 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, PushOnScopeChains(AI, CurBlock->TheScope); } + + if (AI->isInvalidDecl()) + CurBlock->TheDecl->setInvalidDecl(); } } diff --git a/clang/test/AST/ast-dump-recovery.m b/clang/test/AST/ast-dump-recovery.m index c2bd078959aba1..37fa8045c0b941 100644 --- a/clang/test/AST/ast-dump-recovery.m +++ b/clang/test/AST/ast-dump-recovery.m @@ -24,3 +24,9 @@ void k(Foo *foo) { int (^gh63863)() = ^() { return undef; }; + +// CHECK: `-BlockExpr {{.*}} 'int (^)(int, int)' +// CHECK-NEXT: `-BlockDecl {{.*}} invalid +int (^gh64005)(int, int) = ^(int, undefined b) { + return 1; +}; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits