@@ -1630,9 +1630,6 @@ void Sema::MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old) {
1630
1630
/// function declaration are well-formed according to C++
1631
1631
/// [dcl.fct.default].
1632
1632
void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) {
1633
- unsigned NumParams = FD->getNumParams();
1634
- unsigned ParamIdx = 0;
1635
-
1636
1633
// This checking doesn't make sense for explicit specializations; their
1637
1634
// default arguments are determined by the declaration we're specializing,
1638
1635
// not by FD.
@@ -1642,6 +1639,9 @@ void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) {
1642
1639
if (FTD->isMemberSpecialization())
1643
1640
return;
1644
1641
1642
+ unsigned NumParams = FD->getNumParams();
1643
+ unsigned ParamIdx = 0;
1644
+
1645
1645
// Find first parameter with a default argument
1646
1646
for (; ParamIdx < NumParams; ++ParamIdx) {
1647
1647
ParmVarDecl *Param = FD->getParamDecl(ParamIdx);
@@ -1654,21 +1654,19 @@ void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) {
1654
1654
// with a default argument shall have a default argument supplied in this or
1655
1655
// a previous declaration, unless the parameter was expanded from a
1656
1656
// parameter pack, or shall be a function parameter pack.
1657
- for (; ParamIdx < NumParams; ++ParamIdx) {
1657
+ for (++ParamIdx ; ParamIdx < NumParams; ++ParamIdx) {
1658
1658
ParmVarDecl *Param = FD->getParamDecl(ParamIdx);
1659
- if (! Param->hasDefaultArg() && ! Param->isParameterPack() &&
1660
- ! (CurrentInstantiationScope &&
1661
- CurrentInstantiationScope->isLocalPackExpansion(Param))) {
1662
- if (Param->isInvalidDecl())
1663
- /* We already complained about this parameter. */;
1664
- else if (Param->getIdentifier())
1665
- Diag (Param->getLocation(),
1666
- diag::err_param_default_argument_missing_name)
1659
+ if (Param->hasDefaultArg() || Param->isParameterPack() ||
1660
+ (CurrentInstantiationScope &&
1661
+ CurrentInstantiationScope->isLocalPackExpansion(Param)))
1662
+ continue;
1663
+ if (Param->isInvalidDecl())
1664
+ /* We already complained about this parameter. */;
1665
+ else if (Param->getIdentifier())
1666
+ Diag(Param->getLocation(), diag::err_param_default_argument_missing_name)
1667
1667
<< Param->getIdentifier();
1668
- else
1669
- Diag(Param->getLocation(),
1670
- diag::err_param_default_argument_missing);
1671
- }
1668
+ else
1669
+ Diag(Param->getLocation(), diag::err_param_default_argument_missing);
1672
1670
}
1673
1671
}
1674
1672
0 commit comments