llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Oleksandr Tarasiuk (a-tarasyuk) <details> <summary>Changes</summary> The fix for #<!-- -->183290 introduced `setInvalidDecl()` in `AddOverriddenMethods` based on the result of `CheckOverridingFunctionExceptionSpec`, which returns `true` for **any** spec mismatch - including warning-only cases such as a missing `__declspec(nothrow)` on an override in MSVCCompat mode. This caused valid methods to be incorrectly marked invalid. Exception spec mismatches do not affect a method's type or calling convention and should not make an override structurally invalid. --- Full diff: https://github.com/llvm/llvm-project/pull/199895.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) - (modified) clang/test/SemaCXX/MicrosoftCompatibility.cpp (+17) ``````````diff 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 { `````````` </details> https://github.com/llvm/llvm-project/pull/199895 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
