Skip to content

Commit 3cb16f6

Browse files
committed
[Sema][ObjC] Invalidate BlockDecl with invalid ParmVarDecl
BlockDecl should be invalidated because of its invalid ParmVarDecl. Fixes #1 of llvm/llvm-project#64005 Differential Revision: https://reviews.llvm.org/D155984
1 parent 585cbe3 commit 3cb16f6

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

clang/docs/ReleaseNotes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,8 @@ Bug Fixes in This Version
674674
value exprs is invalid. Propagating the error info up by replacing BlockExpr
675675
with a RecoveryExpr. This fixes:
676676
(`#63863 <https://github.com/llvm/llvm-project/issues/63863>_`)
677+
- Invalidate BlockDecl with invalid ParmVarDecl
678+
(`#64005 <https://github.com/llvm/llvm-project/issues/64005>_`)
677679

678680
Bug Fixes to Compiler Builtins
679681
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaExpr.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -16959,6 +16959,9 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
1695916959

1696016960
PushOnScopeChains(AI, CurBlock->TheScope);
1696116961
}
16962+
16963+
if (AI->isInvalidDecl())
16964+
CurBlock->TheDecl->setInvalidDecl();
1696216965
}
1696316966
}
1696416967

clang/test/AST/ast-dump-recovery.m

+6
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ void k(Foo *foo) {
2424
int (^gh63863)() = ^() {
2525
return undef;
2626
};
27+
28+
// CHECK: `-BlockExpr {{.*}} 'int (^)(int, int)'
29+
// CHECK-NEXT: `-BlockDecl {{.*}} invalid
30+
int (^gh64005)(int, int) = ^(int, undefined b) {
31+
return 1;
32+
};

0 commit comments

Comments
 (0)