diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -187,6 +187,8 @@ - Fix crash in __builtin_strncmp and related builtins when the size value exceeded the maximum value representable by int64_t. Fixes (`#64876 `_) +- Fixed an assertion if a function has cleanups and fatal erors. + (`#48974 `_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -16013,6 +16013,7 @@ // 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 --- /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); +}