Skip to content

[clang] Fix a bug with qualified name lookup into current instantiation #73018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ Bug Fixes in This Version
- Fix crash when the object used as a ``static_assert`` message has ``size`` or ``data`` members
which are not member functions.
- Support UDLs in ``static_assert`` message.
- Fixed false positive error emitted by clang when performing qualified name
lookup and the current class instantiation has dependent bases.
Fixes (`#13826 <https://github.com/llvm/llvm-project/issues/13826>`_)

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
14 changes: 12 additions & 2 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc,
UsingShadowDecl *FoundUsingShadow = nullptr;
switch (Result.getResultKind()) {
case LookupResult::NotFound:
case LookupResult::NotFoundInCurrentInstantiation:
if (CorrectedII) {
TypeNameValidatorCCC CCC(/*AllowInvalid=*/true, isClassName,
AllowDeducedTemplate);
Expand Down Expand Up @@ -482,7 +481,18 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc,
}
}
}
// If typo correction failed or was not performed, fall through
Result.suppressDiagnostics();
return nullptr;
case LookupResult::NotFoundInCurrentInstantiation:
if (AllowImplicitTypename == ImplicitTypenameContext::Yes) {
QualType T = Context.getDependentNameType(ElaboratedTypeKeyword::None,
SS->getScopeRep(), &II);
TypeLocBuilder TLB;
DependentNameTypeLoc TL = TLB.push<DependentNameTypeLoc>(T);
TL.setQualifierLoc(SS->getWithLocInContext(Context));
TL.setNameLoc(NameLoc);
return CreateParsedType(T, TLB.getTypeSourceInfo(Context, T));
}
[[fallthrough]];
case LookupResult::FoundOverloaded:
case LookupResult::FoundUnresolvedValue:
Expand Down
14 changes: 14 additions & 0 deletions clang/test/SemaTemplate/dependent-base-classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,17 @@ namespace PR5812 {

Derived<int> di;
}

namespace GH13826 {
template <typename T> struct A {
typedef int type;
struct B;
};

template <typename T> struct A<T>::B : A<T> {
B::type t;
};

A<int> a;
A<int>::B b;
}