https://github.com/HamzaHassanain updated 
https://github.com/llvm/llvm-project/pull/174281

>From aafd57e112ea07a66e2864c9034ac8bbc328c0b2 Mon Sep 17 00:00:00 2001
From: Hamza Hassanain <[email protected]>
Date: Sat, 3 Jan 2026 17:07:05 +0200
Subject: [PATCH 1/4] [Clang][Sema] reject undeduced static members without
 init

---
 clang/lib/Sema/SemaDecl.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 11323803e1910..50a6a4176d1ec 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14337,8 +14337,18 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
         DeduceVariableDeclarationType(Var, false, nullptr))
       return;
 
+    Type = Var->getType();
     this->CheckAttributesOnDeducedType(RealDecl);
 
+    if (auto *Deduced = Type->getContainedDeducedType()) {
+      if (Var->isStaticDataMember() && Deduced->getDeducedType().isNull()) {
+        Diag(Var->getLocation(), diag::err_auto_var_requires_init)
+            << Var->getDeclName() << Type;
+        Var->setInvalidDecl();
+        return;
+      }
+    }
+
     // C++11 [class.static.data]p3: A static data member can be declared with
     // the constexpr specifier; if so, its declaration shall specify
     // a brace-or-equal-initializer.

>From 74473fd4f581b5538e01b8a3c1e9e068f9c88831 Mon Sep 17 00:00:00 2001
From: Hamza Hassanain <[email protected]>
Date: Sat, 3 Jan 2026 17:31:34 +0200
Subject: [PATCH 2/4] [Clang][Test][SemaCXX] added alias tempalte static member
 hanlding test

---
 clang/test/SemaCXX/alias-template-static-member.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 clang/test/SemaCXX/alias-template-static-member.cpp

diff --git a/clang/test/SemaCXX/alias-template-static-member.cpp 
b/clang/test/SemaCXX/alias-template-static-member.cpp
new file mode 100644
index 0000000000000..0089aea33cc80
--- /dev/null
+++ b/clang/test/SemaCXX/alias-template-static-member.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template <class T>
+struct A {
+  template <class U>
+  using E = U;
+
+  static E u; // expected-error {{declaration of variable 'u' with deduced 
type 'E' requires an initializer}}
+};
+
+decltype(A<int>::u) a;
\ No newline at end of file

>From ddba6f35cd9aa85631f26388e618e41b279701d2 Mon Sep 17 00:00:00 2001
From: Hamza Hassanain <[email protected]>
Date: Sat, 3 Jan 2026 22:22:46 +0200
Subject: [PATCH 3/4] [Clang][Sema] Remove redundunt logic and call
 getContainedDeducedType instead?

---
 clang/lib/Sema/SemaDecl.cpp | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 50a6a4176d1ec..795bbda8ddc77 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14333,22 +14333,12 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
       return;
     }
 
-    if (Type->isUndeducedType() &&
+    if (Type->getContainedDeducedType() &&
         DeduceVariableDeclarationType(Var, false, nullptr))
       return;
 
-    Type = Var->getType();
     this->CheckAttributesOnDeducedType(RealDecl);
 
-    if (auto *Deduced = Type->getContainedDeducedType()) {
-      if (Var->isStaticDataMember() && Deduced->getDeducedType().isNull()) {
-        Diag(Var->getLocation(), diag::err_auto_var_requires_init)
-            << Var->getDeclName() << Type;
-        Var->setInvalidDecl();
-        return;
-      }
-    }
-
     // C++11 [class.static.data]p3: A static data member can be declared with
     // the constexpr specifier; if so, its declaration shall specify
     // a brace-or-equal-initializer.

>From c1792109fc5172db229cb85d20432d60fb12ba34 Mon Sep 17 00:00:00 2001
From: Hamza Hassanain <[email protected]>
Date: Sat, 3 Jan 2026 22:23:14 +0200
Subject: [PATCH 4/4] [Clang][docs] added a relase not

---
 clang/docs/ReleaseNotes.rst | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2319ff13f7864..9da6ea13fe234 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -623,6 +623,10 @@ Bug Fixes to C++ Support
 - Fix the result of ``__is_pointer_interconvertible_base_of`` when arguments 
are qualified and passed via template parameters. (#GH135273)
 - Fixed a crash when evaluating nested requirements in requires-expressions 
that reference invented parameters. (#GH166325)
 - Fixed a crash when standard comparison categories (e.g. 
``std::partial_ordering``) are defined with incorrect static member types. 
(#GH170015) (#GH56571)
+- Fixed a crash where Clang would attempt to generate code for a static data 
+  member declared with an alias template without template arguments. 
+  Clang now correctly diagnoses this as an undeduced type and rejects 
+  the declaration. (#GH173349)
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^

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

Reply via email to