Skip to content

Commit f0c66e9

Browse files
committed
[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
1 parent 7cd6179 commit f0c66e9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4568,6 +4568,7 @@ Sema::BuildMemInitializer(Decl *ConstructorD,
45684568
MarkAnyDeclReferenced(TyD->getLocation(), TyD, /*OdrUse=*/false);
45694569

45704570
TypeLocBuilder TLB;
4571+
// FIXME: This is missing building the UsingType for TyD, if any.
45714572
if (const auto *TD = dyn_cast<TagDecl>(TyD)) {
45724573
BaseType = Context.getTagType(ElaboratedTypeKeyword::None,
45734574
SS.getScopeRep(), TD, /*OwnsTag=*/false);
@@ -4581,6 +4582,12 @@ Sema::BuildMemInitializer(Decl *ConstructorD,
45814582
TLB.push<TypedefTypeLoc>(BaseType).set(
45824583
/*ElaboratedKeywordLoc=*/SourceLocation(),
45834584
SS.getWithLocInContext(Context), IdLoc);
4585+
} else if (auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TyD)) {
4586+
BaseType = Context.getUnresolvedUsingType(ElaboratedTypeKeyword::None,
4587+
SS.getScopeRep(), UD);
4588+
TLB.push<UnresolvedUsingTypeLoc>(BaseType).set(
4589+
/*ElaboratedKeywordLoc=*/SourceLocation(),
4590+
SS.getWithLocInContext(Context), IdLoc);
45844591
} else {
45854592
// FIXME: What else can appear here?
45864593
assert(SS.isEmpty());

clang/test/SemaTemplate/class-template-ctor-initializer.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
template<class X> struct A {};
66

7-
template<class X> struct B : A<X> {
8-
B() : A<X>() {}
7+
template<class X> struct B : A<X> {
8+
B() : A<X>() {}
99
};
1010
B<int> x;
1111

@@ -76,3 +76,12 @@ namespace NonDependentError {
7676
Derived1<void> d1;
7777
Derived2<void> d2;
7878
}
79+
80+
namespace UnresolvedUsing {
81+
template <class T> class A {
82+
using typename T::B;
83+
struct C : B {
84+
C() : B() {}
85+
};
86+
};
87+
} // namespace UnresolvedUsing

0 commit comments

Comments
 (0)