diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -172,6 +172,8 @@ - Clang now prints unnamed members in diagnostic messages instead of giving an empty ''. Fixes (`#63759 `_) +- 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); +}