https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/199895
>From 466b5ed1d2622bdc04514e9ca317842d5608fb70 Mon Sep 17 00:00:00 2001 From: Oleksandr Tarasiuk <[email protected]> Date: Wed, 27 May 2026 10:39:48 +0300 Subject: [PATCH] [Clang] fix crash on override with warning-only exception spec mismatch --- clang/lib/Sema/SemaDecl.cpp | 2 +- clang/test/SemaCXX/MicrosoftCompatibility.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 62cb9360d1322..74ba5d3adf3cd 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9268,9 +9268,9 @@ bool Sema::AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) { bool Invalid = false; Invalid |= CheckOverridingFunctionReturnType(MD, BaseMD); Invalid |= CheckOverridingFunctionAttributes(MD, BaseMD); - Invalid |= CheckOverridingFunctionExceptionSpec(MD, BaseMD); if (Invalid) MD->setInvalidDecl(); + CheckOverridingFunctionExceptionSpec(MD, BaseMD); CheckIfOverriddenFunctionIsMarkedFinal(MD, BaseMD); } diff --git a/clang/test/SemaCXX/MicrosoftCompatibility.cpp b/clang/test/SemaCXX/MicrosoftCompatibility.cpp index b8cd22ad350a5..66545770737aa 100644 --- a/clang/test/SemaCXX/MicrosoftCompatibility.cpp +++ b/clang/test/SemaCXX/MicrosoftCompatibility.cpp @@ -391,6 +391,23 @@ void f6() noexcept; // expected-note {{previous declaration is here}} void f6() {} // expected-error {{'f6' is missing exception specification 'noexcept'}} } +namespace GH183290 { +struct A { + virtual __declspec(nothrow) long __stdcall d(); // expected-note {{overridden virtual function is here}} +}; +struct B : A { + long __stdcall d(); // expected-warning {{exception specification of overriding function is more lax than base version}} +}; +struct C { + B *operator->(); +}; + +C a; +void test() { + if (auto g = a->d()) {} +} +} + namespace PR43265 { template <int N> // expected-note {{template parameter is declared here}} struct Foo { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
