Author: Aric Maji
Date: 2026-10-26T06:41:55Z
New Revision: 1fd3d78da2230cef4410aad912f666b8bab5a7d9

URL: 
https://github.com/llvm/llvm-project/commit/1fd3d78da2230cef4410aad912f666b8bab5a7d9
DIFF: 
https://github.com/llvm/llvm-project/commit/1fd3d78da2230cef4410aad912f666b8bab5a7d9.diff

LOG: [Clang][Sema] Add regression test for GH138098 (#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

Co-authored-by: Rishika11052 <[email protected]>

Added: 
    clang/test/SemaCXX/gh138098.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/clang/test/SemaCXX/gh138098.cpp b/clang/test/SemaCXX/gh138098.cpp
new file mode 100644
index 0000000000000..e06ecc1817a83
--- /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@+3 {{explicit qualification required to use member 
'type_c' from dependent base class}}
+        // expected-error@+2 {{comparison between pointer and integer ('int' 
and 'auto &(*)()')}}
+        // expected-note@8 {{in instantiation of member function 
'Derived<int>::type_c' requested here}}
+        if (index != type_c<T>) {}
+    }
+    // expected-error@+2 {{cannot deduce return type 'auto &' for function 
with no return statements}}
+    // expected-note@12 {{member is declared here}}
+    static auto& type_c() { }
+};
+
+int main() {
+    Derived<int> d;
+    // expected-note@19 {{in instantiation of member function 
'Derived<int>::f' requested here}}
+    // expected-note@19 {{in instantiation of member function 
'Derived<int>::f' requested here}}
+    d.f(0);
+}


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

Reply via email to