https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/84671
Try to fix https://github.com/llvm/llvm-project/issues/84368 [temp.friend]p1: Similarly, each specialization of the `task` class template has the class template specialization `task<int>` as a friend, and has all specializations of the class template `frd` as friends. >From 9abe798955b0db77e12f0aec43cd23926a2b4744 Mon Sep 17 00:00:00 2001 From: huqizhi <huqi...@feysh.com> Date: Sun, 10 Mar 2024 16:11:18 +0800 Subject: [PATCH] [Clang][Sema] Fix a bug on type constraint checking --- clang/docs/ReleaseNotes.rst | 2 ++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 1 + clang/test/Sema/PR84368.cpp | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 clang/test/Sema/PR84368.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3b89d5a8720785..b32e739288dbc5 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -259,6 +259,8 @@ Bug Fixes in This Version operator. Fixes (#GH83267). +- Fix a bug on type constraint checking (#GH84368). + Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 20c2c93ac9c7b4..765c5bc689ae1e 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1698,6 +1698,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { assert(!Owner->isDependentContext()); Inst->setLexicalDeclContext(Owner); RecordInst->setLexicalDeclContext(Owner); + Inst->setObjectOfFriendDecl(); if (PrevClassTemplate) { Inst->setCommonPtr(PrevClassTemplate->getCommonPtr()); diff --git a/clang/test/Sema/PR84368.cpp b/clang/test/Sema/PR84368.cpp new file mode 100644 index 00000000000000..073530ffd8abea --- /dev/null +++ b/clang/test/Sema/PR84368.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// RUN: %clang_cc1 -std=c++23 -verify %s +// expected-no-diagnostics + +template<class T> concept IsOk = requires() { typename T::Float; }; + +template<IsOk T> struct Thing; + +template<IsOk T> struct Foobar { + template<int> struct Inner { + template<IsOk T2> friend struct Thing; + }; +}; + +struct MyType { using Float=float; }; +Foobar<MyType>::Inner<0> foobar; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits