[clang] 6ed05a0 - Revert "[Clang] prevent constexpr crash on invalid overrides" (#199895)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 28 00:41:17 PDT 2026
Author: Oleksandr Tarasiuk
Date: 2026-05-28T10:41:11+03:00
New Revision: 6ed05a0b53dc777408305333dcbeec9dac4ea687
URL: https://github.com/llvm/llvm-project/commit/6ed05a0b53dc777408305333dcbeec9dac4ea687
DIFF: https://github.com/llvm/llvm-project/commit/6ed05a0b53dc777408305333dcbeec9dac4ea687.diff
LOG: Revert "[Clang] prevent constexpr crash on invalid overrides" (#199895)
Reverts #184048
---
The original change marks invalid overrides too early, causing follow-up
Sema regressions in special-member handling and MS-compatible override
diagnostics.
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/constant-expression-cxx14.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6f5f9bacf5c18..11cce36a0906c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -638,7 +638,6 @@ Bug Fixes in This Version
- Fixed the behavior in C23 of ``auto``, by emitting an error when an array type is specified for a ``char *``. (#GH162694)
- Fixed an issue where an assert was thrown instead of an error if no vulkan env was specified with ``--triple spirv``. (#GH189964)
- Fixed incorrect rejection of ``auto`` with reordered declaration specifiers in C23. (#GH164121)
-- Fixed a crash where constexpr evaluation encountered invalid overrides. (#GH183290)
- Fixed a bug where Clang fails to find instantiation of Decls in constraint checking. (#GH173086)
- Fixed a crash when assigning to an element of an ``ext_vector_type`` with ``bool`` element type. (#GH189260)
- Fixed a crash caused by declaring multiple ``ownership_returns`` attributes with mismatched or missing arguments. (#GH188733)
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1a249e5b428f8..daba729d0d440 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9265,12 +9265,9 @@ bool Sema::AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) {
continue;
if (Overridden.insert(BaseMD).second) {
MD->addOverriddenMethod(BaseMD);
- bool Invalid = false;
- Invalid |= CheckOverridingFunctionReturnType(MD, BaseMD);
- Invalid |= CheckOverridingFunctionAttributes(MD, BaseMD);
- Invalid |= CheckOverridingFunctionExceptionSpec(MD, BaseMD);
- if (Invalid)
- MD->setInvalidDecl();
+ CheckOverridingFunctionReturnType(MD, BaseMD);
+ CheckOverridingFunctionAttributes(MD, BaseMD);
+ CheckOverridingFunctionExceptionSpec(MD, BaseMD);
CheckIfOverriddenFunctionIsMarkedFinal(MD, BaseMD);
}
diff --git a/clang/test/SemaCXX/constant-expression-cxx14.cpp b/clang/test/SemaCXX/constant-expression-cxx14.cpp
index 1bead18080271..c64466700808a 100644
--- a/clang/test/SemaCXX/constant-expression-cxx14.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx14.cpp
@@ -1466,29 +1466,3 @@ constexpr bool missingCase() {
1u: return false; // expected-error {{expected 'case' keyword before expression}}
}
}
-
-namespace GH183290 {
-struct A {
- constexpr char a() const { return 'Z'; }
- char b = a();
-};
-
-// expected-error at +1 {{expected class name}}
-struct B : sizeof(int[c]) {};
-
-struct C {
- B b;
- // expected-note at +1 {{overridden virtual function is here}}
- virtual const A *d() const;
-};
-
-struct D : C {
- // expected-error at +1 {{return type of virtual function 'd' is not covariant with the return type of the function it overrides ('const B *' is not derived from 'const A *')}}
- constexpr virtual const B *d() const { return &this->b; }
-};
-
-constexpr D e;
-constexpr const C *f = &e;
-// expected-error at +1 {{static assertion expression is not an integral constant expression}}
-static_assert(f->d()->b == 'Z', "");
-}
More information about the cfe-commits
mailing list