@@ -3264,7 +3264,8 @@ static void propagateAttributes(ParmVarDecl *toDecl,
32643264
32653265/// mergeParamDeclAttributes - Copy attributes from the old parameter
32663266/// to the new one.
3267- static void mergeParamDeclAttributes(ParmVarDecl *newDecl, ParmVarDecl *oldDecl,
3267+ static void mergeParamDeclAttributes(ParmVarDecl *newDecl,
3268+ const ParmVarDecl *oldDecl,
32683269 Sema &S) {
32693270 // C++11 [dcl.attr.depend]p2:
32703271 // The first declaration of a function shall specify the
@@ -3284,20 +3285,12 @@ static void mergeParamDeclAttributes(ParmVarDecl *newDecl, ParmVarDecl *oldDecl,
32843285 diag::note_carries_dependency_missing_first_decl) << 1/*Param*/;
32853286 }
32863287
3287- // Forward propagation (from old parameter to new)
32883288 propagateAttributes(
32893289 newDecl, oldDecl, [&S](ParmVarDecl *toDecl, const ParmVarDecl *fromDecl) {
32903290 unsigned found = 0;
32913291 found += propagateAttribute<InheritableParamAttr>(toDecl, fromDecl, S);
3292- return found;
3293- });
3294-
3295- // Backward propagation (from new parameter to old)
3296- propagateAttributes(
3297- oldDecl, newDecl, [&S](ParmVarDecl *toDecl, const ParmVarDecl *fromDecl) {
3298- unsigned found = 0;
32993292 // Propagate the lifetimebound attribute from parameters to the
3300- // canonical declaration. Note that this doesn't include the implicit
3293+ // most recent declaration. Note that this doesn't include the implicit
33013294 // 'this' parameter, as the attribute is applied to the function type in
33023295 // that case.
33033296 found += propagateAttribute<LifetimeBoundAttr>(toDecl, fromDecl, S);
@@ -4356,8 +4349,8 @@ void Sema::mergeObjCMethodDecls(ObjCMethodDecl *newMethod,
43564349 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
43574350
43584351 // Merge attributes from the parameters.
4359- ObjCMethodDecl::param_iterator oi = oldMethod->param_begin(),
4360- oe = oldMethod->param_end();
4352+ ObjCMethodDecl::param_const_iterator oi = oldMethod->param_begin(),
4353+ oe = oldMethod->param_end();
43614354 for (ObjCMethodDecl::param_iterator
43624355 ni = newMethod->param_begin(), ne = newMethod->param_end();
43634356 ni != ne && oi != oe; ++ni, ++oi)
@@ -6981,6 +6974,7 @@ static void checkInheritableAttr(Sema &S, NamedDecl &ND) {
69816974static void checkLifetimeBoundAttr(Sema &S, NamedDecl &ND) {
69826975 // Check the attributes on the function type and function params, if any.
69836976 if (const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
6977+ FD = FD->getMostRecentDecl();
69846978 // Don't declare this variable in the second operand of the for-statement;
69856979 // GCC miscompiles that by ending its lifetime before evaluating the
69866980 // third operand. See gcc.gnu.org/PR86769.
0 commit comments