llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: None (NewSigma) <details> <summary>Changes</summary> Fix #<!-- -->129411 --- Full diff: https://github.com/llvm/llvm-project/pull/131328.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+4) - (modified) clang/test/Parser/cxx-template-decl.cpp (+8) ``````````diff 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) { `````````` </details> https://github.com/llvm/llvm-project/pull/131328 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits