summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp5
-rw-r--r--clang/test/CodeGenCXX/new.cpp4
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 5e46090c058..8599a146c69 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1257,8 +1257,11 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
Context.getCanonicalType(
Func->getParamDecl(0)->getType().getUnqualifiedType());
// FIXME: Do we need to check for default arguments here?
- if (Func->getNumParams() == 1 && InitialParamType == Argument)
+ if (Func->getNumParams() == 1 && InitialParamType == Argument) {
+ if(AddMallocAttr && !Func->hasAttr<MallocAttr>())
+ Func->addAttr(::new (Context) MallocAttr());
return;
+ }
}
}
}
diff --git a/clang/test/CodeGenCXX/new.cpp b/clang/test/CodeGenCXX/new.cpp
index 3f22e89f2a5..61a5a153ca5 100644
--- a/clang/test/CodeGenCXX/new.cpp
+++ b/clang/test/CodeGenCXX/new.cpp
@@ -73,6 +73,10 @@ void t8(int n) {
new U[n];
}
+// noalias
+// CHECK: declare noalias i8* @_Znam
+void *operator new[](size_t);
+
void t9() {
bool b;
OpenPOWER on IntegriCloud