summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d24a653b348..c5df3ed0169 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2090,15 +2090,6 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
}
}
- // If the function is sized operator delete and has not already been
- // declared, and weak definitions have been disabled, do not declare
- // it implicitly. Instead, let deallocation function lookup pick up
- // unsized delete.
- // FIXME: We should remove this guard once backward compatibility is
- // no longer an issue
- if (NumParams == 2 && !getLangOpts().DefineSizedDeallocation)
- return;
-
FunctionProtoType::ExtProtoInfo EPI;
QualType BadAllocType;
@@ -2131,6 +2122,16 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
Alloc->addAttr(VisibilityAttr::CreateImplicit(Context,
VisibilityAttr::Default));
+ if (NumParams == 2 && !getLangOpts().DefineSizedDeallocation) {
+ assert(getLangOpts().SizedDeallocation &&
+ "Only sized deallocation can have two parameters");
+
+ // This declaration should be emited as extern_weak.
+ LinkageInfo LV = Alloc->getLinkageAndVisibility();
+ assert(LV.getLinkage() == clang::ExternalLinkage);
+ Alloc->addAttr(WeakAttr::CreateImplicit(Context));
+ }
+
if (AddRestrictAttr)
Alloc->addAttr(
RestrictAttr::CreateImplicit(Context, RestrictAttr::GNU_malloc));
OpenPOWER on IntegriCloud