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)
return ExprError();
}
+ MarkDeclarationReferenced(StartLoc, OperatorDelete);
+
// FIXME: Check access and ambiguity of operator delete and destructor.
}
-// 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
-// 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 {
-// 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
-// RUN: %clang_cc1 %s -emit-llvm -o %t
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
void t1(int *a) {
delete a;
int a;
};
+// CHECK: define void @_Z2t4P1T
void t4(T *t) {
- // RUN: grep "call void @_ZN1TD1Ev" %t | count 1
+ // CHECK: call void @_ZN1TD1Ev
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @_ZdlPv
delete t;
}
delete a;
}
+
+namespace test0 {
+ struct A {
+ void *operator new(__SIZE_TYPE__ sz);
+ void operator delete(void *p) { ::operator delete(p); }
+ ~A() {}
+ };
+
+ // CHECK: define void @_ZN5test04testEPNS_1AE(
+ void test(A *a) {
+ // CHECK: call void @_ZN5test01AD1Ev
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @_ZN5test01AdlEPv
+ delete a;
+ }
+
+ // CHECK: define linkonce_odr void @_ZN5test01AD1Ev
+ // CHECK: define linkonce_odr void @_ZN5test01AdlEPv
+}
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Various tests for -fno-exceptions
+
+typedef __SIZE_TYPE__ 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();
+ }
+}