https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/199895

>From bfb5212059d1655f48cf207ade8bf1e06bb945b9 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk <[email protected]>
Date: Thu, 28 May 2026 10:04:24 +0300
Subject: [PATCH] Revert "[Clang] prevent constexpr crash on invalid overrides"

---
 clang/docs/ReleaseNotes.rst                   |  1 -
 clang/lib/Sema/SemaDecl.cpp                   |  9 +++----
 .../SemaCXX/constant-expression-cxx14.cpp     | 26 -------------------
 3 files changed, 3 insertions(+), 33 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f3865672120e0..5f0497e12319f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -632,7 +632,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 62cb9360d1322..8477fdf00d777 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@+1 {{expected class name}}
-struct B : sizeof(int[c]) {};
-
-struct C {
-  B b;
-  // expected-note@+1 {{overridden virtual function is here}}
-  virtual const A *d() const;
-};
-
-struct D : C {
-  // expected-error@+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@+1 {{static assertion expression is not an integral constant 
expression}}
-static_assert(f->d()->b == 'Z', "");
-}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to