Skip to content

Commit fd1711b

Browse files
author
huqizhi
committed
[Clang][Sema] Fix a bug on type constraint checking
1 parent 71590e7 commit fd1711b

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ Bug Fixes to C++ Support
351351
when one of the function had more specialized templates.
352352
Fixes (`#82509 <https://github.com/llvm/llvm-project/issues/82509>`_)
353353
and (`#74494 <https://github.com/llvm/llvm-project/issues/74494>`_)
354+
- Fix an issue where missing set friend declaration in template class instantiation.
355+
Fixes (#GH84368).
354356

355357
Bug Fixes to AST Handling
356358
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
16981698
assert(!Owner->isDependentContext());
16991699
Inst->setLexicalDeclContext(Owner);
17001700
RecordInst->setLexicalDeclContext(Owner);
1701+
Inst->setObjectOfFriendDecl();
17011702

17021703
if (PrevClassTemplate) {
17031704
Inst->setCommonPtr(PrevClassTemplate->getCommonPtr());

clang/test/Sema/PR84368.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_cc1 -std=c++20 -verify %s
2+
// RUN: %clang_cc1 -std=c++23 -verify %s
3+
// expected-no-diagnostics
4+
5+
template<class T> concept IsOk = requires() { typename T::Float; };
6+
7+
template<IsOk T> struct Thing;
8+
9+
template<IsOk T> struct Foobar {
10+
template<int> struct Inner {
11+
template<IsOk T2> friend struct Thing;
12+
};
13+
};
14+
15+
struct MyType { using Float=float; };
16+
Foobar<MyType>::Inner<0> foobar;

0 commit comments

Comments
 (0)