[clang] [clang] Fix conflicting declaration error with using_if_exists (PR #167646)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 31 14:45:59 PDT 2026
================
@@ -12832,6 +12833,15 @@ bool Sema::CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Orig,
(isa_and_nonnull<UnresolvedUsingIfExistsDecl>(NonTag))) {
if (!NonTag && !Tag)
return false;
+
+ // Only report the error if this using_if_exists decl can be a
+ // substitute for the original decl. LookupResult will find things with
+ // the same name but we also want to take into account namespaces and
+ // other scopes. GlobalDecl helps take care of that.
+ NamedDecl *UsedTag = NonTag ? NonTag : Tag;
+ if (GlobalDecl(Target) != GlobalDecl(UsedTag))
----------------
PiJoules wrote:
TBH I forgot why I used `GlobalDecl` but you're right in pointing out that it just does a pointer comparison in the end, so removed it.
https://github.com/llvm/llvm-project/pull/167646
More information about the cfe-commits
mailing list