[clang] [clang] Add fixit for using declaration with a (qualified) namespace (PR #94762)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 7 08:49:27 PDT 2024
================
@@ -13080,6 +13080,9 @@ NamedDecl *Sema::BuildUsingDeclaration(
if (R.getAsSingle<NamespaceDecl>()) {
Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
<< SS.getRange();
+ // Suggest using 'using namespace ...' instead.
+ Diag(SS.getBeginLoc(), diag::note_namespace_using_decl)
+ << FixItHint::CreateInsertion(SS.getBeginLoc(), "namespace ");
return BuildInvalid();
----------------
zmodem wrote:
I suppose another exercise for our future selves could be to recover as if the user typed "using namespace"
https://github.com/llvm/llvm-project/pull/94762
More information about the cfe-commits
mailing list