[clang] [Clang][Sema] Add regression test for GH138098 (PR #235483)

Aric Maji via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 25 09:38:40 PDT 2026


https://github.com/Adam-Warlock09 created https://github.com/llvm/llvm-project/pull/235483

This adds the missing regression test for GH138098.

As noted by @shafik, the crash described in this issue was inadvertently fixed by #143423 (which removed delayed typo expressions), but the codebase lacked a specific regression test to ensure this ICE (Internal Compiler Error) does not return in the future.

This test verifies that Clang correctly emits diagnostics for invalid dependent names instead of crashing. 

(I verified on Compiler Explorer that this test successfully crashes on older versions of Clang like 17.0.1 up until 20.1.x, and passes on the current `main` branch [From 21.1x onward]).

Fixes #138098

>From 4999d50d063ca595a114af4e2cd3a0864bb23b1b Mon Sep 17 00:00:00 2001
From: Rishika11052 <c24btech11052 at iith.ac.in>
Date: Sun, 25 Oct 2026 16:32:13 +0000
Subject: [PATCH] [Clang][Sema] Add regression test for GH138098

---
 clang/test/SemaCXX/gh138098.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 clang/test/SemaCXX/gh138098.cpp

diff --git a/clang/test/SemaCXX/gh138098.cpp b/clang/test/SemaCXX/gh138098.cpp
new file mode 100644
index 00000000000000..e06ecc1817a837
--- /dev/null
+++ b/clang/test/SemaCXX/gh138098.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+template<typename T> struct Derived {
+    void f(int index) {
+        // expected-error at +3 {{explicit qualification required to use member 'type_c' from dependent base class}}
+        // expected-error at +2 {{comparison between pointer and integer ('int' and 'auto &(*)()')}}
+        // expected-note at 8 {{in instantiation of member function 'Derived<int>::type_c' requested here}}
+        if (index != type_c<T>) {}
+    }
+    // expected-error at +2 {{cannot deduce return type 'auto &' for function with no return statements}}
+    // expected-note at 12 {{member is declared here}}
+    static auto& type_c() { }
+};
+
+int main() {
+    Derived<int> d;
+    // expected-note at 19 {{in instantiation of member function 'Derived<int>::f' requested here}}
+    // expected-note at 19 {{in instantiation of member function 'Derived<int>::f' requested here}}
+    d.f(0);
+}



More information about the cfe-commits mailing list