diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -16959,6 +16959,9 @@ 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 --- a/clang/test/AST/ast-dump-recovery.m +++ b/clang/test/AST/ast-dump-recovery.m @@ -16,3 +16,9 @@ // CHECK-NEXT: `-DeclRefExpr {{.*}} 'foo' foo.undef; } + +// CHECK: `-BlockExpr {{.*}} 'int (^)(int, int)' +// CHECK-NEXT: `-BlockDecl {{.*}} invalid +int (^a)(int, int) = ^(int, undefine b) { + return 1; +};