@@ -6503,10 +6503,10 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D,
65036503 existingAttr->getVisibility();
65046504 if (existingValue != VisibilityAttr::Default)
65056505 Diag(D.getExportLoc(), diag::err_mismatched_visibility);
6506- } else {
6506+ } else
6507+ // Add VisibilityAttr::Default since the default could be hidden, etc
65076508 New->addAttr(
65086509 VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default));
6509- }
65106510 }
65116511
65126512 // If this has an identifier and is not a function template specialization,
@@ -6746,6 +6746,9 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
67466746 return nullptr;
67476747 }
67486748
6749+ if (D.IsExport())
6750+ Diag(D.getName().StartLocation, diag::err_cannot_be_exported);
6751+
67496752 TypedefDecl *NewTD = ParseTypedefDecl(S, D, TInfo->getType(), TInfo);
67506753 if (!NewTD) return nullptr;
67516754
@@ -8208,6 +8211,9 @@ NamedDecl *Sema::ActOnVariableDeclarator(
82088211
82098212 ProcessPragmaWeak(S, NewVD);
82108213
8214+ if (D.IsExport() && !NewVD->hasExternalFormalLinkage())
8215+ Diag(D.getIdentifierLoc(), diag::err_cannot_be_exported);
8216+
82118217 // If this is the first declaration of an extern C variable, update
82128218 // the map of such variables.
82138219 if (NewVD->isFirstDecl() && !NewVD->isInvalidDecl() &&
@@ -10851,6 +10857,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
1085110857 }
1085210858
1085310859 ProcessPragmaWeak(S, NewFD);
10860+
10861+ if (D.IsExport() && !NewFD->hasExternalFormalLinkage())
10862+ Diag(D.getIdentifierLoc(), diag::err_cannot_be_exported);
10863+
1085410864 checkAttributesAfterMerging(*this, *NewFD);
1085510865
1085610866 AddKnownFunctionAttributes(NewFD);
@@ -15343,6 +15353,9 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D,
1534315353 if (getLangOpts().OpenCL)
1534415354 deduceOpenCLAddressSpace(New);
1534515355
15356+ if (D.IsExport())
15357+ Diag(D.getIdentifierLoc(), diag::err_cannot_be_exported);
15358+
1534615359 return New;
1534715360}
1534815361
@@ -18705,6 +18718,9 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
1870518718 } else
1870618719 Record->addDecl(NewFD);
1870718720
18721+ if (D.IsExport())
18722+ Diag(D.getIdentifierLoc(), diag::err_cannot_be_exported);
18723+
1870818724 return NewFD;
1870918725}
1871018726
0 commit comments