[clang] Revert "[Clang] Check enable_if attribute in the DC of current function" (PR #176024)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 14 12:04:19 PST 2026
https://github.com/gulfemsavrun created https://github.com/llvm/llvm-project/pull/176024
Reverts llvm/llvm-project#175899 as it caused an assertion error.
https://ci.chromium.org/ui/p/fuchsia/builders/global.ci/clang_toolchain.ci.core.x64-debug-tot-build_only/b8692683882729058145/overview
>From cef336b1169fc6bc915c13b882045b831a2b3976 Mon Sep 17 00:00:00 2001
From: gulfemsavrun <gulfem at google.com>
Date: Wed, 14 Jan 2026 12:03:33 -0800
Subject: [PATCH] =?UTF-8?q?Revert=20"[Clang]=20Check=20enable=5Fif=20attri?=
=?UTF-8?q?bute=20in=20the=20DC=20of=20current=20function=20(#175=E2=80=A6?=
=?UTF-8?q?"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 28009c8880209a87d83b5901cfaf8d8e96be5693.
---
clang/docs/ReleaseNotes.rst | 1 -
clang/lib/Sema/SemaOverload.cpp | 2 --
clang/test/SemaCXX/enable_if.cpp | 35 --------------------------------
3 files changed, 38 deletions(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c9d21558c94fa..4139d1d80ed4a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -120,7 +120,6 @@ Bug Fixes to Compiler Builtins
Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- Fixed a behavioral discrepancy between deleted functions and private members when checking the ``enable_if`` attribute. (#GH175895)
Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5592cd2545358..7115b8b7d446a 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7551,8 +7551,6 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function,
return nullptr;
SFINAETrap Trap(*this);
- // Switching the DC to ensure the immediate access control checking.
- ContextRAII SavedContext(*this, Function->getDeclContext());
SmallVector<Expr *, 16> ConvertedArgs;
// FIXME: We should look into making enable_if late-parsed.
Expr *DiscardedThis;
diff --git a/clang/test/SemaCXX/enable_if.cpp b/clang/test/SemaCXX/enable_if.cpp
index 845ccf00864a1..1c307881e5d4a 100644
--- a/clang/test/SemaCXX/enable_if.cpp
+++ b/clang/test/SemaCXX/enable_if.cpp
@@ -562,41 +562,6 @@ namespace IgnoreUnusedArgSideEffects {
#endif
}
-namespace GH175895 {
-
-using int32_t = int;
-
-struct wxuin_t {
- wxuin_t() {}
- wxuin_t(int32_t v) __attribute__((enable_if(v == 0, "Expect only constant expressions"))) {}
-};
-
-struct wxuin64_t {
- wxuin64_t() {}
-
- explicit operator wxuin_t() const { return {}; }
-
-private:
- operator int() const { return 0; }
-};
-
-struct wxuin64_t_deleted {
- wxuin64_t_deleted() {}
-
- explicit operator wxuin_t() const { return {}; }
-
- operator int() = delete;
-};
-
-void main() {
- wxuin64_t uin64{};
- wxuin64_t_deleted deleted{};
- auto b = static_cast<wxuin_t>(uin64);
- auto c = static_cast<wxuin_t>(deleted);
-}
-
-}
-
namespace DefaultArgs {
void f(int n = __builtin_LINE()) __attribute__((enable_if(n == 12345, "only callable on line 12345"))); // expected-note {{only callable on line 12345}}
void g() { f(); } // expected-error {{no matching function}}
More information about the cfe-commits
mailing list