From 9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 24 Nov 2014 09:15:30 +0000 Subject: Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release): https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957 --- test/SemaCXX/overloaded-operator.cpp | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'test/SemaCXX/overloaded-operator.cpp') diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp index 99105cb5b60b..feb7c716ff00 100644 --- a/test/SemaCXX/overloaded-operator.cpp +++ b/test/SemaCXX/overloaded-operator.cpp @@ -452,3 +452,70 @@ namespace PR7681 { Result = 1; // expected-error {{no viable overloaded '='}} // expected-note {{type 'PointerUnion' is incomplete}} } } + +namespace PR14995 { + struct B {}; + template void operator++(B, T...) {} + + void f() { + B b; + b++; // ok + ++b; // ok + } + + template + struct C { + void operator-- (T...) {} + }; + + void g() { + C postfix; + C<> prefix; + postfix--; // ok + --prefix; // ok + } + + struct D {}; + template void operator++(D, T) {} + + void h() { + D d; + d++; // ok + ++d; // expected-error{{cannot increment value of type 'PR14995::D'}} + } + + template struct E { + void operator++(T...) {} // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'char')}} + }; + + E e; // expected-note {{in instantiation of template class 'PR14995::E' requested here}} + + struct F { + template + int operator++ (T...) {} + }; + + int k1 = F().operator++(0, 0); + int k2 = F().operator++('0'); + // expected-error@-5 {{overloaded 'operator++' must be a unary or binary operator}} + // expected-note@-3 {{in instantiation of function template specialization 'PR14995::F::operator++' requested here}} + // expected-error@-4 {{no matching member function for call to 'operator++'}} + // expected-note@-8 {{candidate template ignored: substitution failure}} + // expected-error@-9 {{parameter of overloaded post-increment operator must have type 'int' (not 'char')}} + // expected-note@-6 {{in instantiation of function template specialization 'PR14995::F::operator++' requested here}} + // expected-error@-7 {{no matching member function for call to 'operator++'}} + // expected-note@-12 {{candidate template ignored: substitution failure}} +} // namespace PR14995 + +namespace ConversionVersusTemplateOrdering { + struct A { + operator short() = delete; + template operator T(); + } a; + struct B { + template operator T(); + operator short() = delete; + } b; + int x = a; + int y = b; +} -- cgit v1.2.3