]> granicus.if.org Git - clang/commitdiff
Don't bother looking for (or diagnosing problems with) the 'operator delete'
authorJohn McCall <rjmccall@apple.com>
Tue, 20 Apr 2010 00:22:43 +0000 (00:22 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 20 Apr 2010 00:22:43 +0000 (00:22 +0000)
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

lib/Sema/SemaExprCXX.cpp
test/CXX/expr/expr.unary/expr.new/p19.cpp
test/CXX/expr/expr.unary/expr.new/p20-0x.cpp
test/CXX/expr/expr.unary/expr.new/p20.cpp
test/SemaCXX/no-exceptions.cpp [new file with mode: 0644]

index 9440772fc6e43eb1c4dc276e427b256844983310..605f280c4fdbb1253c336d8ce8d163203110d9c1 100644 (file)
@@ -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)
index 6134779f1fd22f96057e135373b7a5df3951f678..bb69fd55fd8034abbb1abc83c4d66aa3b0583fc4 100644 (file)
@@ -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
index c188e1e25e04eb484ec38648959601d155c0210a..4c924b137ccdfe38dd31791d0f3aa5b30167910a 100644 (file)
@@ -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 {
index 71e584e775c3f5c640c7f8b640408e6c5208504c..8cbe2b9be3be72b6c5b251a47a3e7cbecd0f85ba 100644 (file)
@@ -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 (file)
index 0000000..bf2527c
--- /dev/null
@@ -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();
+  }
+}