diff options
author | Daniel Jasper <djasper@google.com> | 2016-10-10 14:13:55 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-10-10 14:13:55 +0000 |
commit | e9abe648166a95a85105f4138ea41b345a66035e (patch) | |
tree | 551aed9b3cc942c9f7f0d0e95b5b02f2a0f8db04 /clang/test | |
parent | 610ad3a5985c1eb40917eb948f5a09266270112c (diff) | |
download | bcm5719-llvm-e9abe648166a95a85105f4138ea41b345a66035e.tar.gz bcm5719-llvm-e9abe648166a95a85105f4138ea41b345a66035e.zip |
Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned allocation."
This reverts commit r283722. Breaks:
Clang.SemaCUDA.device-var-init.cu
Clang.CodeGenCUDA.device-var-init.cu
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/884/
llvm-svn: 283750
Diffstat (limited to 'clang/test')
6 files changed, 4 insertions, 391 deletions
diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp deleted file mode 100644 index 9e3210c6650..00000000000 --- a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fexceptions -verify %s - -using size_t = decltype(sizeof(0)); - -namespace std { enum class align_val_t : size_t {}; } - -// p2 says "A template instance is never a usual deallocation function, -// regardless of its signature." We (and every other implementation) assume -// this means "A function template specialization [...]" -template<typename...Ts> struct A { - void *operator new(size_t); - void operator delete(void*, Ts...) = delete; // expected-note 4{{deleted}} -}; - -auto *a1 = new A<>; // expected-error {{deleted}} -auto *a2 = new A<size_t>; // expected-error {{deleted}} -auto *a3 = new A<std::align_val_t>; // expected-error {{deleted}} -auto *a4 = new A<size_t, std::align_val_t>; // expected-error {{deleted}} -auto *a5 = new A<std::align_val_t, size_t>; // ok, not usual diff --git a/clang/test/CXX/expr/expr.unary/expr.delete/p10.cpp b/clang/test/CXX/expr/expr.unary/expr.delete/p10.cpp deleted file mode 100644 index aad2747dd32..00000000000 --- a/clang/test/CXX/expr/expr.unary/expr.delete/p10.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -using size_t = decltype(sizeof(0)); -namespace std { enum class align_val_t : size_t {}; } - -// Aligned version is preferred over unaligned version, -// unsized version is preferred over sized version. -template<unsigned Align> -struct alignas(Align) A { - void operator delete(void*); - void operator delete(void*, std::align_val_t) = delete; // expected-note {{here}} - - void operator delete(void*, size_t) = delete; - void operator delete(void*, size_t, std::align_val_t) = delete; -}; -void f(A<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; } -void f(A<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}} - -template<unsigned Align> -struct alignas(Align) B { - void operator delete(void*, size_t); - void operator delete(void*, size_t, std::align_val_t) = delete; // expected-note {{here}} -}; -void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; } -void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}} diff --git a/clang/test/CXX/expr/expr.unary/expr.new/p14.cpp b/clang/test/CXX/expr/expr.unary/expr.new/p14.cpp deleted file mode 100644 index 6537cdcfeaf..00000000000 --- a/clang/test/CXX/expr/expr.unary/expr.new/p14.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fexceptions %s -verify - -using size_t = decltype(sizeof(0)); -namespace std { enum class align_val_t : size_t {}; } - -struct Arg {} arg; - -// If the type is aligned, first try with an alignment argument and then -// without. If not, never consider supplying an alignment. - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Unaligned { - void *operator new(size_t, Ts...) = delete; // expected-note 4{{deleted}} -}; -auto *ua = new Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{deleted}} -auto *ub = new Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *uap = new (arg) Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{deleted}} -auto *ubp = new (arg) Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Aligned { - void *operator new(size_t, std::align_val_t, Ts...) = delete; // expected-note 2{{deleted}} expected-note 2{{not viable}} -}; -auto *aa = new Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{no matching}} -auto *ab = new Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *aap = new (arg) Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{no matching}} -auto *abp = new (arg) Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} - -// If both are available, we prefer the aligned version for an overaligned -// type, and only use the unaligned version for a non-overaligned type. - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Both1 { - void *operator new(size_t, Ts...); // expected-note 2{{not viable}} - void *operator new(size_t, std::align_val_t, Ts...) = delete; // expected-note 2{{deleted}} -}; -template<unsigned Align, typename ...Ts> -struct alignas(Align) Both2 { - void *operator new(size_t, Ts...) = delete; // expected-note 2{{deleted}} - void *operator new(size_t, std::align_val_t, Ts...); // expected-note 2{{not viable}} -}; -auto *b1a = new Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; -auto *b1b = new Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *b2a = new Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{deleted}} -auto *b2b = new Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; -auto *b1ap = new (arg) Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; -auto *b1bp = new (arg) Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} -auto *b2ap = new (arg) Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{deleted}} -auto *b2bp = new (arg) Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; - -// Note that the aligned form can select a function with a parameter different -// from std::align_val_t. - -struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) WeirdAlignedAlloc1 { - void *operator new(size_t, ...) = delete; // expected-note 2{{deleted}} -}; -auto *waa1 = new WeirdAlignedAlloc1; // expected-error {{deleted}} -auto *waa1p = new (arg) WeirdAlignedAlloc1; // expected-error {{deleted}} - -struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) WeirdAlignedAlloc2 { - template<typename ...T> - void *operator new(size_t, T...) { - using U = void(T...); // expected-note 2{{previous}} - using U = void; // expected-error {{different types ('void' vs 'void (std::align_val_t)')}} \ - expected-error {{different types ('void' vs 'void (std::align_val_t, Arg)')}} - } -}; -auto *waa2 = new WeirdAlignedAlloc2; // expected-note {{instantiation of}} -auto *waa2p = new (arg) WeirdAlignedAlloc2; // expected-note {{instantiation of}} diff --git a/clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp b/clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp index 13676a8a07c..eca1ec79019 100644 --- a/clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp +++ b/clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp @@ -1,10 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fexceptions %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -fexceptions %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -fexceptions %s typedef __SIZE_TYPE__ size_t; -namespace std { enum class align_val_t : size_t {}; } - struct S { // Placement allocation function: static void* operator new(size_t, size_t); @@ -13,56 +9,5 @@ struct S { }; void testS() { - S* p = new (0) S; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} -} - -struct T { - // Placement allocation function: - static void* operator new(size_t, size_t); - // Usual (non-placement) deallocation function: - static void operator delete(void*); - // Placement deallocation function: - static void operator delete(void*, size_t); -}; - -void testT() { - T* p = new (0) T; // ok -} - -#if __cplusplus > 201402L -struct U { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Placement deallocation function: - static void operator delete(void*, size_t, std::align_val_t); // expected-note{{declared here}} -}; - -void testU() { - U* p = new (0, std::align_val_t(0)) U; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} -} - -struct V { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Usual (non-placement) deallocation function: - static void operator delete(void*, std::align_val_t); - // Placement deallocation function: - static void operator delete(void*, size_t, std::align_val_t); -}; - -void testV() { - V* p = new (0, std::align_val_t(0)) V; -} - -struct W { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Usual (non-placement) deallocation functions: - static void operator delete(void*); - static void operator delete(void*, size_t, std::align_val_t); // expected-note {{declared here}} -}; - -void testW() { - W* p = new (0, std::align_val_t(0)) W; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} + S* p = new (0) S; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} } -#endif diff --git a/clang/test/CXX/special/class.dtor/p9.cpp b/clang/test/CXX/special/class.dtor/p9.cpp index 4c6fbf43437..cfde48b0aab 100644 --- a/clang/test/CXX/special/class.dtor/p9.cpp +++ b/clang/test/CXX/special/class.dtor/p9.cpp @@ -31,13 +31,13 @@ namespace test0 { namespace test1 { class A { public: - static void operator delete(void *p) {}; + static void operator delete(void *p) {}; // expected-note {{member 'operator delete' declared here}} virtual ~A(); }; class B : protected A { public: - static void operator delete(void *, size_t) {}; + static void operator delete(void *, size_t) {}; // expected-note {{member 'operator delete' declared here}} ~B(); }; @@ -49,20 +49,7 @@ namespace test1 { ~C(); }; - // We assume that the intent is to treat C::operator delete(void*, size_t) as - // /not/ being a usual deallocation function, as it would be if it were - // declared with in C directly. - C::~C() {} - - struct D { - void operator delete(void*); // expected-note {{member 'operator delete' declared here}} - void operator delete(void*, ...); // expected-note {{member 'operator delete' declared here}} - virtual ~D(); - }; - // FIXME: The standard doesn't say this is ill-formed, but presumably either - // it should be or the variadic operator delete should not be a usual - // deallocation function. - D::~D() {} // expected-error {{multiple suitable 'operator delete' functions in 'D'}} + C::~C() {} // expected-error {{multiple suitable 'operator delete' functions in 'C'}} } // ...at the point of definition of a virtual destructor... diff --git a/clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp b/clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp deleted file mode 100644 index 437597d963b..00000000000 --- a/clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// Check that delete exprs call aligned (de)allocation functions if -// -faligned-allocation is passed in both C++11 and C++14. -// RUN: %clang_cc1 -std=c++11 -fexceptions -fsized-deallocation -faligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s -// RUN: %clang_cc1 -std=c++14 -fexceptions -fsized-deallocation -faligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s -// RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s - -// Check that we don't used aligned (de)allocation without -faligned-allocation or C++1z. -// RUN: %clang_cc1 -std=c++14 -DUNALIGNED -fexceptions %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNALIGNED -// RUN: %clang_cc1 -std=c++1z -DUNALIGNED -fexceptions -fno-aligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNALIGNED - -// CHECK-UNALIGNED-NOT: _Znwm_St11align_val_t -// CHECK-UNALIGNED-NOT: _Znam_St11align_val_t -// CHECK-UNALIGNED-NOT: _ZdlPv_St11align_val_t -// CHECK-UNALIGNED-NOT: _ZdaPv_St11align_val_t -// CHECK-UNALIGNED-NOT: _ZdlPvm_St11align_val_t -// CHECK-UNALIGNED-NOT: _ZdaPvm_St11align_val_t - -typedef decltype(sizeof(0)) size_t; -namespace std { enum class align_val_t : size_t {}; } - -#define OVERALIGNED alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) - -// Global new and delete. -// ====================== -struct OVERALIGNED A { A(); int n[128]; }; - -// CHECK-LABEL: define {{.*}} @_Z2a0v() -// CHECK: %[[ALLOC:.*]] = call i8* @_ZnwmSt11align_val_t(i64 512, i64 32) -// CHECK: call void @_ZdlPvSt11align_val_t(i8* %[[ALLOC]], i64 32) -void *a0() { return new A; } - -// CHECK-LABEL: define {{.*}} @_Z2a1l( -// CHECK: %[[ALLOC:.*]] = call i8* @_ZnamSt11align_val_t(i64 %{{.*}}, i64 32) -// No array cookie. -// CHECK-NOT: store -// CHECK: invoke void @_ZN1AC1Ev( -// CHECK: call void @_ZdaPvSt11align_val_t(i8* %[[ALLOC]], i64 32) -void *a1(long n) { return new A[n]; } - -// CHECK-LABEL: define {{.*}} @_Z2a2P1A( -// CHECK: call void @_ZdlPvmSt11align_val_t(i8* %{{.*}}, i64 512, i64 32) #9 -void a2(A *p) { delete p; } - -// CHECK-LABEL: define {{.*}} @_Z2a3P1A( -// CHECK: call void @_ZdaPvSt11align_val_t(i8* %{{.*}}, i64 32) #9 -void a3(A *p) { delete[] p; } - - -// Class-specific usual new and delete. -// ==================================== -struct OVERALIGNED B { - B(); - // These are just a distraction. We should ignore them. - void *operator new(size_t); - void operator delete(void*, size_t); - void operator delete[](void*, size_t); - - void *operator new(size_t, std::align_val_t); - void operator delete(void*, std::align_val_t); - void operator delete[](void*, std::align_val_t); - - int n[128]; -}; - -// CHECK-LABEL: define {{.*}} @_Z2b0v() -// CHECK: %[[ALLOC:.*]] = call i8* @_ZN1BnwEmSt11align_val_t(i64 512, i64 32) -// CHECK: call void @_ZN1BdlEPvSt11align_val_t(i8* %[[ALLOC]], i64 32) -void *b0() { return new B; } - -// CHECK-LABEL: define {{.*}} @_Z2b1l( -// CHECK: %[[ALLOC:.*]] = call i8* @_ZnamSt11align_val_t(i64 %{{.*}}, i64 32) -// No array cookie. -// CHECK-NOT: store -// CHECK: invoke void @_ZN1BC1Ev( -// CHECK: call void @_ZN1BdaEPvSt11align_val_t(i8* %[[ALLOC]], i64 32) -void *b1(long n) { return new B[n]; } - -// CHECK-LABEL: define {{.*}} @_Z2b2P1B( -// CHECK: call void @_ZN1BdlEPvSt11align_val_t(i8* %{{.*}}, i64 32) -void b2(B *p) { delete p; } - -// CHECK-LABEL: define {{.*}} @_Z2b3P1B( -// CHECK: call void @_ZN1BdaEPvSt11align_val_t(i8* %{{.*}}, i64 32) -void b3(B *p) { delete[] p; } - -struct OVERALIGNED C { - C(); - void *operator new[](size_t, std::align_val_t); - void operator delete[](void*, size_t, std::align_val_t); - - // It doesn't matter that we have an unaligned operator delete[] that doesn't - // want the size. What matters is that the aligned one does. - void operator delete[](void*); -}; - -// This one has an array cookie. -// CHECK-LABEL: define {{.*}} @_Z2b4l( -// CHECK: call {{.*}} @llvm.umul.with.overflow{{.*}}i64 32 -// CHECK: call {{.*}} @llvm.uadd.with.overflow{{.*}}i64 32 -// CHECK: %[[ALLOC:.*]] = call i8* @_ZN1CnaEmSt11align_val_t(i64 %{{.*}}, i64 32) -// CHECK: store -// CHECK: call void @_ZN1CC1Ev( -// -// Note, we're still calling a placement allocation function, and there is no -// matching placement operator delete. =( -// FIXME: This seems broken. -// CHECK-NOT: call void @_ZN1CdaEPvmSt11align_val_t( -#ifndef UNALIGNED -void *b4(long n) { return new C[n]; } -#endif - -// CHECK-LABEL: define {{.*}} @_Z2b5P1C( -// CHECK: mul i64{{.*}} 32 -// CHECK: add i64{{.*}} 32 -// CHECK: call void @_ZN1CdaEPvmSt11align_val_t( -void b5(C *p) { delete[] p; } - - -// Global placement new. -// ===================== - -struct Q { int n; } q; -void *operator new(size_t, Q); -void *operator new(size_t, std::align_val_t, Q); -void operator delete(void*, Q); -void operator delete(void*, std::align_val_t, Q); - -// CHECK-LABEL: define {{.*}} @_Z2c0v( -// CHECK: %[[ALLOC:.*]] = call i8* @_ZnwmSt11align_val_t1Q(i64 512, i64 32, i32 % -// CHECK: call void @_ZdlPvSt11align_val_t1Q(i8* %[[ALLOC]], i64 32, i32 % -void *c0() { return new (q) A; } - - -// Class-specific placement new. -// ============================= - -struct OVERALIGNED D { - D(); - void *operator new(size_t, Q); - void *operator new(size_t, std::align_val_t, Q); - void operator delete(void*, Q); - void operator delete(void*, std::align_val_t, Q); -}; - -// CHECK-LABEL: define {{.*}} @_Z2d0v( -// CHECK: %[[ALLOC:.*]] = call i8* @_ZN1DnwEmSt11align_val_t1Q(i64 32, i64 32, i32 % -// CHECK: call void @_ZN1DdlEPvSt11align_val_t1Q(i8* %[[ALLOC]], i64 32, i32 % -void *d0() { return new (q) D; } - - -// Calling aligned new with placement syntax. -// ========================================== - -#ifndef UNALIGNED -// CHECK-LABEL: define {{.*}} @_Z2e0v( -// CHECK: %[[ALLOC:.*]] = call i8* @_ZnwmSt11align_val_t(i64 512, i64 5) -// CHECK: call void @_ZdlPvSt11align_val_t(i8* %[[ALLOC]], i64 5) -void *e0() { return new (std::align_val_t(5)) A; } - -// CHECK-LABEL: define {{.*}} @_Z2e1v( -// CHECK: %[[ALLOC:.*]] = call i8* @_ZN1BnwEmSt11align_val_t(i64 512, i64 5) -// CHECK: call void @_ZN1BdlEPvSt11align_val_t(i8* %[[ALLOC]], i64 5) -void *e1() { return new (std::align_val_t(5)) B; } -#endif - -// Variadic placement/non-placement allocation functions. -// ====================================================== - -struct OVERALIGNED F { - F(); - void *operator new(size_t, ...); - void operator delete(void*, ...); - int n[128]; -}; - -// CHECK-LABEL: define {{.*}} @_Z2f0v( -// CHECK: %[[ALLOC:.*]] = call i8* (i64, ...) @_ZN1FnwEmz(i64 512, i64 32) -// Non-placement allocation function, uses normal deallocation lookup which -// cares about whether a parameter has type std::align_val_t. -// CHECK: call void (i8*, ...) @_ZN1FdlEPvz(i8* %[[ALLOC]]) -void *f0() { return new F; } - -// CHECK-LABEL: define {{.*}} @_Z2f1v( -// CHECK: %[[ALLOC:.*]] = call i8* (i64, ...) @_ZN1FnwEmz(i64 512, i64 32, i32 % -// Placement allocation function, uses placement deallocation matching, which -// passes same arguments and therefore includes alignment. -// CHECK: call void (i8*, ...) @_ZN1FdlEPvz(i8* %[[ALLOC]], i64 32, i32 % -void *f1() { return new (q) F; } - -struct OVERALIGNED G { - G(); - void *operator new(size_t, std::align_val_t, ...); - void operator delete(void*, std::align_val_t, ...); - int n[128]; -}; -#ifndef UNALIGNED -// CHECK-LABEL: define {{.*}} @_Z2g0v -// CHECK: %[[ALLOC:.*]] = call i8* (i64, i64, ...) @_ZN1GnwEmSt11align_val_tz(i64 512, i64 32) -// CHECK: call void (i8*, i64, ...) @_ZN1GdlEPvSt11align_val_tz(i8* %[[ALLOC]], i64 32) -void *g0() { return new G; } - -// CHECK-LABEL: define {{.*}} @_Z2g1v -// CHECK: %[[ALLOC:.*]] = call i8* (i64, i64, ...) @_ZN1GnwEmSt11align_val_tz(i64 512, i64 32, i32 % -// CHECK: call void (i8*, i64, ...) @_ZN1GdlEPvSt11align_val_tz(i8* %[[ALLOC]], i64 32, i32 % -void *g1() { return new (q) G; } -#endif |