diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-02-04 01:14:30 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-02-04 01:14:30 +0000 |
commit | bdd146435ff77f63c83823eeec4d763c6fb9a2d8 (patch) | |
tree | d61a74713f68cd0623c1ea8e690bc79f74c0e800 /clang/test | |
parent | 7437589fa186d1f0e58d7528bf9b7351fae5ffdc (diff) | |
download | bcm5719-llvm-bdd146435ff77f63c83823eeec4d763c6fb9a2d8.tar.gz bcm5719-llvm-bdd146435ff77f63c83823eeec4d763c6fb9a2d8.zip |
Add implicit declarations of allocation functions when looking them up for
redeclaration, not just when looking them up for a use -- we need the implicit
declaration to appropriately check various properties of them (notably, whether
they're deleted).
llvm-svn: 200729
Diffstat (limited to 'clang/test')
4 files changed, 18 insertions, 8 deletions
diff --git a/clang/test/Analysis/NewDelete-variadic.cpp b/clang/test/Analysis/NewDelete-variadic.cpp index 53dba463bbf..62a7d17e1b2 100644 --- a/clang/test/Analysis/NewDelete-variadic.cpp +++ b/clang/test/Analysis/NewDelete-variadic.cpp @@ -5,15 +5,19 @@ namespace std { typedef __typeof__(sizeof(int)) size_t; } -void *operator new(std::size_t, ...); -void *operator new[](std::size_t, ...); +struct X {}; + +void *operator new(std::size_t, X, ...); +void *operator new[](std::size_t, X, ...); void testGlobalCustomVariadicNew() { - void *p1 = operator new(0); // no warn + X x; + + void *p1 = operator new(0, x); // no warn - void *p2 = operator new[](0); // no warn + void *p2 = operator new[](0, x); // no warn - int *p3 = new int; // no warn + int *p3 = new (x) int; // no warn - int *p4 = new int[0]; // no warn + int *p4 = new (x) int[0]; // no warn } diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp index 8a62ae84e2a..3b77a62ce7d 100644 --- a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp +++ b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp @@ -9,7 +9,8 @@ namespace NS { void *operator new(size_t);; // expected-error {{'operator new' cannot be declared inside a namespace}} } -static void *operator new(size_t); // expected-error {{'operator new' cannot be declared static in global scope}} +static void *operator new(size_t); // expected-error {{static declaration of 'operator new' follows non-static declaration}} expected-note {{previous}} +static void *operator new(size_t, int, int); // expected-error {{'operator new' cannot be declared static in global scope}} struct B { void operator new(size_t); // expected-error {{'operator new' must return type 'void *'}} diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp index e00e9486f0b..09dde8efde0 100644 --- a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp +++ b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp @@ -8,4 +8,5 @@ namespace NS { void operator delete(void *); // expected-error {{'operator delete' cannot be declared inside a namespace}} } -static void operator delete(void *); // expected-error {{'operator delete' cannot be declared static in global scope}} +static void operator delete(void *); // expected-error {{follows non-static declaration}} expected-note {{implicit}} +static void operator delete(void *, int, int); // expected-error {{'operator delete' cannot be declared static in global scope}} diff --git a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp index b1078dc404b..94d5c297efa 100644 --- a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp +++ b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp @@ -80,3 +80,7 @@ struct except_spec_d_match : except_spec_a, except_spec_b { // (but not normal definitions) struct S { S(); }; S::S() __attribute((pure)) = default; + +using size_t = decltype(sizeof(0)); +void *operator new(size_t) = delete; // expected-error {{deleted definition must be first declaration}} expected-note {{implicit}} +void operator delete(void *) = delete; // expected-error {{deleted definition must be first declaration}} expected-note {{implicit}} |