https://github.com/NewSigma created https://github.com/llvm/llvm-project/pull/131328
Fix #129411 >From df25106771358fd30eec246b7f1c35f4625f63f9 Mon Sep 17 00:00:00 2001 From: NewSigma <newsi...@163.com> Date: Fri, 14 Mar 2025 20:35:38 +0800 Subject: [PATCH] Fix #129411 --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaDeclCXX.cpp | 4 ++++ clang/test/Parser/cxx-template-decl.cpp | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6456acfcc2ada..bf042c50e8b6d 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -310,6 +310,7 @@ Bug Fixes to C++ Support - Clang now correctly parses ``if constexpr`` expressions in immediate function context. (#GH123524) - Fixed an assertion failure affecting code that uses C++23 "deducing this". (#GH130272) - Clang now properly instantiates destructors for initialized members within non-delegating constructors. (#GH93251) +- Correctly diagnoses if unresolved using declarations shadows template paramters (#GH129411) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 673f7eafca7fb..a02bd8335fa20 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -12895,6 +12895,10 @@ NamedDecl *Sema::BuildUsingDeclaration( SS, NameInfo, IdentLoc)) return nullptr; + if (Previous.isSingleResult() && + Previous.getFoundDecl()->isTemplateParameter()) + DiagnoseTemplateParameterShadow(IdentLoc, Previous.getFoundDecl()); + if (HasTypenameKeyword) { // FIXME: not all declaration name kinds are legal here D = UnresolvedUsingTypenameDecl::Create(Context, CurContext, diff --git a/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp index 476341686a64b..a0460da7563ed 100644 --- a/clang/test/Parser/cxx-template-decl.cpp +++ b/clang/test/Parser/cxx-template-decl.cpp @@ -109,6 +109,14 @@ template<template<typename> class T> struct shadow8 { // expected-note{{template template<template<typename> class T> struct inner; // expected-error{{declaration of 'T' shadows template parameter}} }; +template<class> +class shadow9_; + +template<class T> // expected-note{{template parameter is declared here}} +class shadow9 : public shadow9_<T> { + using typename shadow9_<T>::T; // expected-error{{declaration of 'T' shadows template parameter}} +}; + // Non-type template parameters in scope template<int Size> void f(int& i) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits