Skip to content

Commit

Permalink
[Sema][ObjC] Invalidate BlockDecl with invalid ParmVarDecl
Browse files Browse the repository at this point in the history
BlockDecl should be invalidated because of its invalid ParmVarDecl.

Fixes #1 of llvm#64005

Differential Revision: https://reviews.llvm.org/D155984
  • Loading branch information
danix800 committed Jul 24, 2023
1 parent 585cbe3 commit 3cb16f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16959,6 +16959,9 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,

PushOnScopeChains(AI, CurBlock->TheScope);
}

if (AI->isInvalidDecl())
CurBlock->TheDecl->setInvalidDecl();
}
}

Expand Down
6 changes: 6 additions & 0 deletions clang/test/AST/ast-dump-recovery.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 3cb16f6

Please sign in to comment.