diff options
author | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2025-08-14 14:18:51 +0800 |
---|---|---|
committer | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2025-08-14 14:23:14 +0800 |
commit | ab5a5a90c03d25392fcc486a8c587d0dd9b7a0c6 (patch) | |
tree | 2ef34501df0ae355fc3e345672afb3b152b1e952 /clang/lib/Sema/SemaDecl.cpp | |
parent | 23b65edfbcdc867a24087ec9decebd8f326b045a (diff) | |
download | llvm-ab5a5a90c03d25392fcc486a8c587d0dd9b7a0c6.zip llvm-ab5a5a90c03d25392fcc486a8c587d0dd9b7a0c6.tar.gz llvm-ab5a5a90c03d25392fcc486a8c587d0dd9b7a0c6.tar.bz2 |
[C++20] [Modules] Fix incorrect diagnostic for using befriend target
Close https://github.com/llvm/llvm-project/issues/138558
The compiler failed to understand the redeclaration-relationship when
performing checks when MergeFunctionDecl. This seemed to be a complex
circular problem (how can we know the redeclaration relationship before
performing merging?). But the fix seems to be easy and safe. It is fine
to only perform the check only if the using decl is a local decl.
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index cb59782..6581d4c 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3653,7 +3653,9 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, FunctionDecl *Old = OldD->getAsFunction(); if (!Old) { if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(OldD)) { - if (New->getFriendObjectKind()) { + // We don't need to check the using friend pattern from other module unit + // since we should have diagnosed such cases in its unit already. + if (New->getFriendObjectKind() && !OldD->isInAnotherModuleUnit()) { Diag(New->getLocation(), diag::err_using_decl_friend); Diag(Shadow->getTargetDecl()->getLocation(), diag::note_using_decl_target); |