[clang] 5ade434 - [clang] Fix assertion fail when function has cleanups and fatal errors
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 28 02:30:00 PDT 2023
Author: Podchishchaeva, Mariya
Date: 2023-08-28T02:25:57-07:00
New Revision: 5ade434a7e74f44d59a3863ddaf4762c97e1181b
URL: https://github.com/llvm/llvm-project/commit/5ade434a7e74f44d59a3863ddaf4762c97e1181b
DIFF: https://github.com/llvm/llvm-project/commit/5ade434a7e74f44d59a3863ddaf4762c97e1181b.diff
LOG: [clang] Fix assertion fail when function has cleanups and fatal errors
Fixes https://github.com/llvm/llvm-project/issues/48974
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/D158827
Added:
clang/test/SemaCXX/gh48974.cpp
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6dc3c1c5fbcef8..deb53303a21b44 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -187,6 +187,8 @@ Bug Fixes in This Version
- Fix crash in __builtin_strncmp and related builtins when the size value
exceeded the maximum value representable by int64_t. Fixes
(`#64876 <https://github.com/llvm/llvm-project/issues/64876>`_)
+- Fixed an assertion if a function has cleanups and fatal erors.
+ (`#48974 <https://github.com/llvm/llvm-project/issues/48974>`_)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4eacc05f85e69e..664af4ccf4c635 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16013,6 +16013,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
// been leftover. This ensures that these temporaries won't be picked up
// for deletion in some later function.
if (hasUncompilableErrorOccurred() ||
+ hasAnyUnrecoverableErrorsInThisFunction() ||
getDiagnostics().getSuppressAllDiagnostics()) {
DiscardCleanupsInEvaluationContext();
}
diff --git a/clang/test/SemaCXX/gh48974.cpp b/clang/test/SemaCXX/gh48974.cpp
new file mode 100644
index 00000000000000..7963107b06f5ea
--- /dev/null
+++ b/clang/test/SemaCXX/gh48974.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -Werror=unused-parameter -Wfatal-errors -verify %s
+
+void a(int &&s) {} // expected-error{{unused parameter 's'}}
+
+void b() {
+ int sum = a(0);
+}
More information about the cfe-commits
mailing list