From: John McCall Date: Tue, 20 Apr 2010 00:22:43 +0000 (+0000) Subject: Don't bother looking for (or diagnosing problems with) the 'operator delete' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af5ece5017d59bd43ccd6dbe172a1f5b57132ff9;p=clang Don't bother looking for (or diagnosing problems with) the 'operator delete' associated with a new expression if -fno-exceptions is set. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101841 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 9440772fc6..605f280c4f 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -886,6 +886,13 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, return true; } + // We don't need an operator delete if we're running under + // -fno-exceptions. + if (!getLangOptions().Exceptions) { + OperatorDelete = 0; + return false; + } + // FindAllocationOverload can change the passed in arguments, so we need to // copy them back. if (NumPlaceArgs > 0) diff --git a/test/CXX/expr/expr.unary/expr.new/p19.cpp b/test/CXX/expr/expr.unary/expr.new/p19.cpp index 6134779f1f..bb69fd55fd 100644 --- a/test/CXX/expr/expr.unary/expr.new/p19.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p19.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s typedef __SIZE_TYPE__ size_t; // Operator delete template for placement new with global lookup diff --git a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp b/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp index c188e1e25e..4c924b137c 100644 --- a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fexceptions %s typedef __SIZE_TYPE__ size_t; struct S { diff --git a/test/CXX/expr/expr.unary/expr.new/p20.cpp b/test/CXX/expr/expr.unary/expr.new/p20.cpp index 71e584e775..8cbe2b9be3 100644 --- a/test/CXX/expr/expr.unary/expr.new/p20.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p20.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s typedef __SIZE_TYPE__ size_t; // Overloaded operator delete with two arguments diff --git a/test/SemaCXX/no-exceptions.cpp b/test/SemaCXX/no-exceptions.cpp new file mode 100644 index 0000000000..bf2527cacb --- /dev/null +++ b/test/SemaCXX/no-exceptions.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Various tests for -fno-exceptions + +typedef __typeof(sizeof(int)) size_t; + +namespace test0 { + // rdar://problem/7878149 + class Foo { + public: + void* operator new(size_t x); + private: + void operator delete(void *x); + }; + + void test() { + // Under -fexceptions, this does access control for the associated + // 'operator delete'. + (void) new Foo(); + } +}