This revision was automatically updated to reflect the committed changes. Closed by commit rGd89c6530fdb5: [Clang] Fix filtering of inline namespaces for friend functions (authored by shafik). Herald added a project: clang.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147762/new/ https://reviews.llvm.org/D147762 Files: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/test/SemaTemplate/friend.cpp Index: clang/test/SemaTemplate/friend.cpp =================================================================== --- clang/test/SemaTemplate/friend.cpp +++ clang/test/SemaTemplate/friend.cpp @@ -148,3 +148,21 @@ template struct T<X1>; int n = f((X1*)nullptr); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'std::nullptr_t'}} } + +namespace GH61851 { +namespace A { +inline namespace B { + inline constexpr struct {} foo; +} + +template <typename T> +class Bar { + template <typename U> + friend void foo(U &&arg) {} // no diagnostic expected +}; +} + +void foobar() { + A::Bar<int> b; +} +} Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2293,7 +2293,7 @@ // Filter out previous declarations that don't match the scope. The only // effect this has is to remove declarations found in inline namespaces // for friend declarations with unqualified names. - if (isFriend && !QualifierLoc && !FunctionTemplate) { + if (isFriend && !QualifierLoc) { SemaRef.FilterLookupForScope(Previous, DC, /*Scope=*/ nullptr, /*ConsiderLinkage=*/ true, QualifierLoc.hasQualifier());
Index: clang/test/SemaTemplate/friend.cpp =================================================================== --- clang/test/SemaTemplate/friend.cpp +++ clang/test/SemaTemplate/friend.cpp @@ -148,3 +148,21 @@ template struct T<X1>; int n = f((X1*)nullptr); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'std::nullptr_t'}} } + +namespace GH61851 { +namespace A { +inline namespace B { + inline constexpr struct {} foo; +} + +template <typename T> +class Bar { + template <typename U> + friend void foo(U &&arg) {} // no diagnostic expected +}; +} + +void foobar() { + A::Bar<int> b; +} +} Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2293,7 +2293,7 @@ // Filter out previous declarations that don't match the scope. The only // effect this has is to remove declarations found in inline namespaces // for friend declarations with unqualified names. - if (isFriend && !QualifierLoc && !FunctionTemplate) { + if (isFriend && !QualifierLoc) { SemaRef.FilterLookupForScope(Previous, DC, /*Scope=*/ nullptr, /*ConsiderLinkage=*/ true, QualifierLoc.hasQualifier());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits