[clang] Revert "Avoid assert in substqualifier (#182707)" (PR #196755)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Sat May 9 14:08:43 PDT 2026
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/196755
This reverts commit e2def106757534b07a2d3ff15ddd48e14b69a66d.
>From 97ba148d0efc7d9f6c8ebbd3be827320726b8c07 Mon Sep 17 00:00:00 2001
From: Oliver Hunt <oliver at apple.com>
Date: Sat, 9 May 2026 14:07:39 -0700
Subject: [PATCH] Revert "Avoid assert in substqualifier (#182707)"
This reverts commit e2def106757534b07a2d3ff15ddd48e14b69a66d.
---
clang/docs/ReleaseNotes.rst | 1 -
clang/lib/Sema/SemaDecl.cpp | 4 +---
clang/test/SemaTemplate/GH176152.cpp | 12 ------------
3 files changed, 1 insertion(+), 16 deletions(-)
delete mode 100644 clang/test/SemaTemplate/GH176152.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0d43f864653cc..c17143e3c0398 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -572,7 +572,6 @@ Bug Fixes to C++ Support
- Correctly diagnose uses of ``co_await`` / ``co_yield`` in the default argument of nested function declarations. (#GH98923)
- Fixed a crash when diagnosing an invalid static member function with an explicit object parameter (#GH177741)
- Clang incorrectly instantiated variable specializations outside of the immediate context. (#GH54439)
-- Fixed a crash when instantiating an invalid out-of-line static data member definition in a local class. (#GH176152)
- Fixed a crash when pack expansions are used as arguments for non-pack parameters of built-in templates. (#GH180307)
- Fix a problem where pack index expressions where incorrectly being regarded as equivalent.
- Fixed a bug where captured variables in non-mutable lambdas were incorrectly treated as mutable
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7c5bcd56b346c..a9a4cb89d115f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7926,7 +7926,7 @@ NamedDecl *Sema::ActOnVariableDeclarator(
if (CurContext->isRecord()) {
if (SC == SC_Static) {
- if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
+ if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
// Walk up the enclosing DeclContexts to check for any that are
// incompatible with static data members.
const DeclContext *FunctionOrMethod = nullptr;
@@ -7948,8 +7948,6 @@ NamedDecl *Sema::ActOnVariableDeclarator(
Diag(D.getIdentifierLoc(),
diag::err_static_data_member_not_allowed_in_local_class)
<< Name << RD->getDeclName() << RD->getTagKind();
- Invalid = true;
- RD->setInvalidDecl();
} else if (AnonStruct) {
// C++ [class.static.data]p4: Unnamed classes and classes contained
// directly or indirectly within unnamed classes shall not contain
diff --git a/clang/test/SemaTemplate/GH176152.cpp b/clang/test/SemaTemplate/GH176152.cpp
deleted file mode 100644
index 7d61aa292982d..0000000000000
--- a/clang/test/SemaTemplate/GH176152.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
-
-template <class T> int f(T) {
- struct MyClass {
- static int staticField;
- // expected-error at -1 {{static data member 'staticField' not allowed in local struct 'MyClass'}}
- };
- int MyClass::staticField = 42;
- return 0;
-}
-
-int x = f(0);
More information about the cfe-commits
mailing list