Skip to content

Commit 124d6d4

Browse files
committed
[FOLD] add comment
1 parent a8e2c69 commit 124d6d4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4687,6 +4687,25 @@ bool Sema::InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD,
46874687
NamedDecl *Pattern = FD;
46884688
std::optional<ArrayRef<TemplateArgument>> Innermost;
46894689

4690+
// C++ [dcl.fct.default]p4
4691+
// For non-template functions, default arguments can be added in later
4692+
// declarations of a function that inhabit the same scope.
4693+
//
4694+
// C++ [dcl.fct.default]p6
4695+
// Except for member functions of templated classes, the default arguments
4696+
// in a member function definition that appears outside of the class
4697+
// definition are added to the set of default arguments provided by the
4698+
// member function declaration in the class definition; the program is
4699+
// ill-formed if a default constructor, copy or move constructor, or copy
4700+
// or move assignment operator is so declared. Default arguments for a
4701+
// member function of a templated class shall be specified on the initial
4702+
// declaration of the member function within the templated class.
4703+
//
4704+
// We need to collect the template arguments from the context of the function
4705+
// where the default argument was defined. For a specialization of a function
4706+
// template explicitly specialized for an implicit instantiation of a class
4707+
// template, that context is the (implicitly instantiated) declaration in the
4708+
// definition of the class template specialization.
46904709
if (FD->isCXXClassMember() &&
46914710
!isGenericLambdaCallOperatorOrStaticInvokerSpecialization(FD)) {
46924711
if (FunctionTemplateDecl *FTD = FD->getPrimaryTemplate()) {

0 commit comments

Comments
 (0)