Fix crash declaring global allocation function with zero parameters. Fixes PR19968!
authorNick Lewycky <nicholas@mxc.ca>
Sat, 7 Jun 2014 00:43:57 +0000 (00:43 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sat, 7 Jun 2014 00:43:57 +0000 (00:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210388 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/SemaCXX/new-delete.cpp

index 89470725bb310261b8b9fe1f3eddf51403e3777a..7234d4c8327a0fb83174ebac618e810b997d281f 100644 (file)
@@ -2348,7 +2348,7 @@ bool FunctionDecl::isReplaceableGlobalAllocationFunction() const {
     return false;
 
   const FunctionProtoType *FPT = getType()->castAs<FunctionProtoType>();
-  if (FPT->getNumParams() > 2 || FPT->isVariadic())
+  if (FPT->getNumParams() == 0 || FPT->getNumParams() > 2 || FPT->isVariadic())
     return false;
 
   // If this is a single-parameter function, it must be a replaceable global
index 175ebe7fcdaa289adde9d84dfe47c6a8cfd3df9e..cb43458d457866f2cda93d5dc4a83136f7fa42ed 100644 (file)
@@ -521,3 +521,6 @@ class DeletingPlaceholder {
 namespace PR18544 {
   inline void *operator new(size_t); // expected-error {{'operator new' cannot be declared inside a namespace}}
 }
+
+// PR19968
+inline void* operator new(); // expected-error {{'operator new' must have at least one parameter}}