[clang] [clang] Fix conflicting declaration error with using_if_exists (PR #167646)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 11 03:51:20 PST 2025
================
@@ -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))
----------------
Fznamznon wrote:
Hmm, how exactly `GlobalDecl` helps here?
I see it simply stores a pointer, say for a `FunctionDecl`. It is not asking for a canonical decl and then its operator `==` which is used by `!=` operator compares the stored pointers.
https://github.com/llvm/llvm-project/pull/167646
More information about the cfe-commits
mailing list