From d23368b7ce2e1970977c0145ee7c2d02908c2a02 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sat, 7 Jun 2014 00:43:57 +0000 Subject: [PATCH] Fix crash declaring global allocation function with zero parameters. Fixes PR19968! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210388 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Decl.cpp | 2 +- test/SemaCXX/new-delete.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 89470725bb..7234d4c832 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2348,7 +2348,7 @@ bool FunctionDecl::isReplaceableGlobalAllocationFunction() const { return false; const FunctionProtoType *FPT = getType()->castAs(); - 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 diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp index 175ebe7fcd..cb43458d45 100644 --- a/test/SemaCXX/new-delete.cpp +++ b/test/SemaCXX/new-delete.cpp @@ -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}} -- 2.40.0