-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][Sema] Fix a bug on type constraint checking (#84671)
Try to fix #84368 When visiting class members in `TemplateDeclInstantiator::VisitClassTemplateDecl` during `Sema::InstantiateClass`, we miss to set attribute of friend declaration if it is(`isFriend` is true). This will lead to `Sema::AreConstraintExpressionsEqual` return false when invoked in `MatchTemplateParameterKind`. Because it makes `Sema::getTemplateInstantiationArgs` returns incorrect template argument(`MultiLevelTemplateArgumentList`). When we handle `CXXRecordDecl` In `Sema::getTemplateInstantiationArgs`, friend declaration(its parent context is `FileContext`) makes us to choose `LexicalDeclContext` not `DeclContext` and this is what we want. Co-authored-by: huqizhi <836744285@qq.com>
- Loading branch information
Showing
3 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |