https://github.com/nehaGautam07 updated 
https://github.com/llvm/llvm-project/pull/181404

>From ab88ceb4cc10f56e5797fc750b177d695a8beb99 Mon Sep 17 00:00:00 2001
From: neharaj <[email protected]>
Date: Fri, 13 Feb 2026 19:25:11 +0000
Subject: [PATCH] [Sema] Fix crash on invalid operator template-id

---
 clang/lib/Sema/SemaDecl.cpp                            | 4 ++++
 clang/test/SemaCXX/crash-invalid-operator-template.cpp | 7 +++++++
 2 files changed, 11 insertions(+)
 create mode 100644 clang/test/SemaCXX/crash-invalid-operator-template.cpp

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7af6ce62d08dd..daad0c611394a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6101,6 +6101,10 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId 
&Name) {
   }
 
   case UnqualifiedIdKind::IK_TemplateId: {
+
+    if (Name.TemplateId->isInvalid())
+      return DeclarationNameInfo();
+
     TemplateName TName = Name.TemplateId->Template.get();
     SourceLocation TNameLoc = Name.TemplateId->TemplateNameLoc;
     return Context.getNameForTemplate(TName, TNameLoc);
diff --git a/clang/test/SemaCXX/crash-invalid-operator-template.cpp 
b/clang/test/SemaCXX/crash-invalid-operator-template.cpp
new file mode 100644
index 0000000000000..7a7b95c612e4d
--- /dev/null
+++ b/clang/test/SemaCXX/crash-invalid-operator-template.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef(( operator | <> ) ) ( class { private: }); 
+// expected-error@-1 {{cannot be defined in a parameter type}}
+// expected-error@-2 {{type specifier is required}}
+// expected-error@-3 {{typedef name must be an identifier}}
+

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

Reply via email to