diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaCXX/conversion-delete-expr.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaCXX/conversion-delete-expr.cpp')
-rw-r--r-- | clang/test/SemaCXX/conversion-delete-expr.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/conversion-delete-expr.cpp b/clang/test/SemaCXX/conversion-delete-expr.cpp new file mode 100644 index 0000000..0f298a8 --- /dev/null +++ b/clang/test/SemaCXX/conversion-delete-expr.cpp @@ -0,0 +1,109 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +// Test1 +struct B { + operator char *(); // expected-note {{candidate function}} +}; + +struct D : B { + operator int *(); // expected-note {{candidate function}} +}; + +void f (D d) +{ + delete d; // expected-error {{ambiguous conversion of delete expression of type 'D' to a pointer}} +} + +// Test2 +struct B1 { + operator int *(); +}; + +struct D1 : B1 { + operator int *(); +}; + +void f1 (D1 d) +{ + delete d; +} + +// Test3 +struct B2 { + operator const int *(); // expected-note {{candidate function}} +}; + +struct D2 : B2 { + operator int *(); // expected-note {{candidate function}} +}; + +void f2 (D2 d) +{ + delete d; // expected-error {{ambiguous conversion of delete expression of type 'D2' to a pointer}} +} + +// Test4 +struct B3 { + operator const int *(); // expected-note {{candidate function}} +}; + +struct A3 { + operator const int *(); // expected-note {{candidate function}} +}; + +struct D3 : A3, B3 { +}; + +void f3 (D3 d) +{ + delete d; // expected-error {{ambiguous conversion of delete expression of type 'D3' to a pointer}} +} + +// Test5 +struct X { + operator int(); + operator int*(); +}; + +void f4(X x) { delete x; delete x; } + +// Test6 +struct X1 { + operator int(); + operator int*(); + template<typename T> operator T*() const; // converts to any pointer! +}; + +void f5(X1 x) { delete x; } // OK. In selecting a conversion to pointer function, template convesions are skipped. + +// Test7 +struct Base { + operator int*(); +}; + +struct Derived : Base { + // not the same function as Base's non-const operator int() + operator int*() const; +}; + +void foo6(const Derived cd, Derived d) { + // overload resolution selects Derived::operator int*() const; + delete cd; + delete d; +} + +// Test8 +struct BB { + template<typename T> operator T*() const; +}; + +struct DD : BB { + template<typename T> operator T*() const; // hides base conversion + operator int *() const; +}; + +void foo7 (DD d) +{ + // OK. In selecting a conversion to pointer function, template convesions are skipped. + delete d; +} |