https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/154592
When building the base type for constructor initializer, the case of an UnresolvedUsingType was not being handled. For the non-dependent case, we are also skipping adding the UsingType, but this is just missing information in the AST. A FIXME for this is added. This fixes a regression introduced in #147835, which was never released, so there are no release notes. Fixes #154436 >From f0c66e9c4a596eebf710106bd41790987bfca16f Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <mizve...@gmail.com> Date: Wed, 20 Aug 2025 15:24:32 -0300 Subject: [PATCH] [clang] build UnresolvedUsingType for constructor initializers When building the base type for constructor initializer, the case of an UnresolvedUsingType was not being handled. For the non-dependent case, we are also skipping adding the UsingType, but this is just missing information in the AST. A FIXME for this is added. This fixes a regression introduced in #147835, which was never released, so there are no release notes. Fixes #154436 --- clang/lib/Sema/SemaDeclCXX.cpp | 7 +++++++ .../class-template-ctor-initializer.cpp | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index fb9cec1b78764..aa7de722c3e94 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -4568,6 +4568,7 @@ Sema::BuildMemInitializer(Decl *ConstructorD, MarkAnyDeclReferenced(TyD->getLocation(), TyD, /*OdrUse=*/false); TypeLocBuilder TLB; + // FIXME: This is missing building the UsingType for TyD, if any. if (const auto *TD = dyn_cast<TagDecl>(TyD)) { BaseType = Context.getTagType(ElaboratedTypeKeyword::None, SS.getScopeRep(), TD, /*OwnsTag=*/false); @@ -4581,6 +4582,12 @@ Sema::BuildMemInitializer(Decl *ConstructorD, TLB.push<TypedefTypeLoc>(BaseType).set( /*ElaboratedKeywordLoc=*/SourceLocation(), SS.getWithLocInContext(Context), IdLoc); + } else if (auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TyD)) { + BaseType = Context.getUnresolvedUsingType(ElaboratedTypeKeyword::None, + SS.getScopeRep(), UD); + TLB.push<UnresolvedUsingTypeLoc>(BaseType).set( + /*ElaboratedKeywordLoc=*/SourceLocation(), + SS.getWithLocInContext(Context), IdLoc); } else { // FIXME: What else can appear here? assert(SS.isEmpty()); diff --git a/clang/test/SemaTemplate/class-template-ctor-initializer.cpp b/clang/test/SemaTemplate/class-template-ctor-initializer.cpp index 6dae20774585e..43a3986fea845 100644 --- a/clang/test/SemaTemplate/class-template-ctor-initializer.cpp +++ b/clang/test/SemaTemplate/class-template-ctor-initializer.cpp @@ -4,8 +4,8 @@ template<class X> struct A {}; -template<class X> struct B : A<X> { - B() : A<X>() {} +template<class X> struct B : A<X> { + B() : A<X>() {} }; B<int> x; @@ -76,3 +76,12 @@ namespace NonDependentError { Derived1<void> d1; Derived2<void> d2; } + +namespace UnresolvedUsing { + template <class T> class A { + using typename T::B; + struct C : B { + C() : B() {} + }; + }; +} // namespace UnresolvedUsing _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits