[clang] [Clang]fix dependent qualified base member lookup crash (PR #199403)
via cfe-commits
cfe-commits at lists.llvm.org
Sun May 24 01:07:11 PDT 2026
https://github.com/Serosh-commits updated https://github.com/llvm/llvm-project/pull/199403
>From 5e00093dc1bb444e51449a093020f747529975b3 Mon Sep 17 00:00:00 2001
From: Serosh-commits <janmejayapanda400 at gmail.com>
Date: Sun, 24 May 2026 07:32:40 +0530
Subject: [PATCH] Fix dependent qualified base member lookup crash
---
clang/lib/AST/CXXInheritance.cpp | 3 +++
clang/test/SemaTemplate/current-instantiation.cpp | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index 29f5916284ebb..23a9f112f9bcd 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -127,6 +127,9 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches) const {
const CXXRecordDecl *Record = this;
while (true) {
+ if (!Record->hasDefinition())
+ return false;
+
for (const auto &I : Record->bases()) {
const auto *Base = I.getType()->getAsCXXRecordDecl();
if (!Base || !(Base->isBeingDefined() || Base->isCompleteDefinition()))
diff --git a/clang/test/SemaTemplate/current-instantiation.cpp b/clang/test/SemaTemplate/current-instantiation.cpp
index 9214bbeb973d6..fdc98638b3923 100644
--- a/clang/test/SemaTemplate/current-instantiation.cpp
+++ b/clang/test/SemaTemplate/current-instantiation.cpp
@@ -247,3 +247,18 @@ namespace RebuildDependentScopeDeclRefExpr {
// FIXME: We should issue a typo-correction here.
template<typename T> N<X<T>::think> X<T>::foo() {} // expected-error {{no member named 'think' in 'RebuildDependentScopeDeclRefExpr::X<T>'}}
}
+
+namespace GH195133 {
+ template <typename T> struct A {
+ void f();
+ };
+
+ template <typename T> struct X {
+ struct S : A<int> {};
+ static void f(S *p) {
+ p->template A<int>::f();
+ }
+ };
+
+ void g() { X<int>::f(nullptr); }
+}
More information about the cfe-commits
mailing list