@@ -6868,25 +6868,26 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
68686868 }
68696869}
68706870
6871- static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
6872- // Ensure that an auto decl is deduced otherwise the checks below might cache
6873- // the wrong linkage.
6874- assert(S.ParsingInitForAutoVars.count(&ND) == 0);
6875-
6871+ static void checkWeakAttr(Sema &S, NamedDecl &ND) {
68766872 // 'weak' only applies to declarations with external linkage.
68776873 if (WeakAttr *Attr = ND.getAttr<WeakAttr>()) {
68786874 if (!ND.isExternallyVisible()) {
68796875 S.Diag(Attr->getLocation(), diag::err_attribute_weak_static);
68806876 ND.dropAttr<WeakAttr>();
68816877 }
68826878 }
6879+ }
6880+
6881+ static void checkWeakRefAttr(Sema &S, NamedDecl &ND) {
68836882 if (WeakRefAttr *Attr = ND.getAttr<WeakRefAttr>()) {
68846883 if (ND.isExternallyVisible()) {
68856884 S.Diag(Attr->getLocation(), diag::err_attribute_weakref_not_static);
68866885 ND.dropAttrs<WeakRefAttr, AliasAttr>();
68876886 }
68886887 }
6888+ }
68896889
6890+ static void checkAliasAttr(Sema &S, NamedDecl &ND) {
68906891 if (auto *VD = dyn_cast<VarDecl>(&ND)) {
68916892 if (VD->hasInit()) {
68926893 if (const auto *Attr = VD->getAttr<AliasAttr>()) {
@@ -6897,7 +6898,9 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
68976898 }
68986899 }
68996900 }
6901+ }
69006902
6903+ static void checkSelectAnyAttr(Sema &S, NamedDecl &ND) {
69016904 // 'selectany' only applies to externally visible variable declarations.
69026905 // It does not apply to functions.
69036906 if (SelectAnyAttr *Attr = ND.getAttr<SelectAnyAttr>()) {
@@ -6907,12 +6910,17 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
69076910 ND.dropAttr<SelectAnyAttr>();
69086911 }
69096912 }
6913+ }
69106914
6915+ static void checkHybridPatchableAttr(Sema &S, NamedDecl &ND) {
69116916 if (HybridPatchableAttr *Attr = ND.getAttr<HybridPatchableAttr>()) {
69126917 if (!ND.isExternallyVisible())
69136918 S.Diag(Attr->getLocation(),
69146919 diag::warn_attribute_hybrid_patchable_non_extern);
69156920 }
6921+ }
6922+
6923+ static void checkInheritableAttr(Sema &S, NamedDecl &ND) {
69166924 if (const InheritableAttr *Attr = getDLLAttr(&ND)) {
69176925 auto *VD = dyn_cast<VarDecl>(&ND);
69186926 bool IsAnonymousNS = false;
@@ -6937,7 +6945,9 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
69376945 ND.setInvalidDecl();
69386946 }
69396947 }
6948+ }
69406949
6950+ static void checkLifetimeBoundAttr(Sema &S, NamedDecl &ND) {
69416951 // Check the attributes on the function type and function params, if any.
69426952 if (const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
69436953 // Don't declare this variable in the second operand of the for-statement;
@@ -6989,6 +6999,20 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
69896999 }
69907000}
69917001
7002+ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
7003+ // Ensure that an auto decl is deduced otherwise the checks below might cache
7004+ // the wrong linkage.
7005+ assert(S.ParsingInitForAutoVars.count(&ND) == 0);
7006+
7007+ checkWeakAttr(S, ND);
7008+ checkWeakRefAttr(S, ND);
7009+ checkAliasAttr(S, ND);
7010+ checkSelectAnyAttr(S, ND);
7011+ checkHybridPatchableAttr(S, ND);
7012+ checkInheritableAttr(S, ND);
7013+ checkLifetimeBoundAttr(S, ND);
7014+ }
7015+
69927016static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
69937017 NamedDecl *NewDecl,
69947018 bool IsSpecialization,
0 commit comments