danix800 created this revision. danix800 added reviewers: hokein, aaron.ballman. danix800 added a project: clang. Herald added a subscriber: kristof.beyls. Herald added a project: All. danix800 requested review of this revision. Herald added a subscriber: cfe-commits.
`BlockDecl` should be invalidated because of its invalid `ParmVarDecl`. Fixes #1 of https://github.com/llvm/llvm-project/issues/64005 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D155984 Files: clang/lib/Sema/SemaExpr.cpp clang/test/AST/ast-dump-recovery.m Index: clang/test/AST/ast-dump-recovery.m =================================================================== --- clang/test/AST/ast-dump-recovery.m +++ 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; +}; Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -16959,6 +16959,9 @@ PushOnScopeChains(AI, CurBlock->TheScope); } + + if (AI->isInvalidDecl()) + CurBlock->TheDecl->setInvalidDecl(); } }
Index: clang/test/AST/ast-dump-recovery.m =================================================================== --- clang/test/AST/ast-dump-recovery.m +++ 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; +}; Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -16959,6 +16959,9 @@ PushOnScopeChains(AI, CurBlock->TheScope); } + + if (AI->isInvalidDecl()) + CurBlock->TheDecl->setInvalidDecl(); } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits