class X { };
X operator+(X, X);
void f(X x) {
x = x + x;
}
struct Y;
struct Z;
struct Y {
Y(const Z&);
};
struct Z {
Z(const Y&);
};
Y operator+(Y, Y);
bool operator-(Y, Y); bool operator-(Z, Z);
void g(Y y, Z z) {
y = y + z;
bool b = y - z; }
struct A {
bool operator==(Z&); };
A make_A();
bool operator==(A&, Z&);
void h(A a, const A ac, Z z) {
make_A() == z; a == z; ac == z; }
struct B {
bool operator==(const B&) const;
void test(Z z) {
make_A() == z; }
};
bool i(B b)
{
return b == b;
}
enum Enum1 { };
enum Enum2 { };
struct E1 {
E1(Enum1) { }
};
struct E2 {
E2(Enum2);
};
float& operator==(E1, E2);
void enum_test(Enum1 enum1, Enum2 enum2, E1 e1, E2 e2, Enum1 next_enum1) {
float &f1 = (e1 == e2);
float &f2 = (enum1 == e2);
float &f3 = (e1 == enum2);
float &f4 = (enum1 == next_enum1); }
class pr5244_foo
{
pr5244_foo(int);
pr5244_foo(char);
};
bool operator==(const pr5244_foo& s1, const pr5244_foo& s2); bool operator==(char c, const pr5244_foo& s);
enum pr5244_bar
{
pr5244_BAR
};
class pr5244_baz
{
public:
pr5244_bar quux;
};
void pr5244_barbaz()
{
pr5244_baz quuux;
(void)(pr5244_BAR == quuux.quux);
}
struct PostInc {
PostInc operator++(int);
PostInc& operator++();
};
struct PostDec {
PostDec operator--(int);
PostDec& operator--();
};
void incdec_test(PostInc pi, PostDec pd) {
const PostInc& pi1 = pi++;
const PostDec& pd1 = pd--;
PostInc &pi2 = ++pi;
PostDec &pd2 = --pd;
}
struct SmartPtr {
int& operator*();
long& operator*() const volatile;
};
void test_smartptr(SmartPtr ptr, const SmartPtr cptr,
const volatile SmartPtr cvptr) {
int &ir = *ptr;
long &lr = *cptr;
long &lr2 = *cvptr;
}
struct ArrayLike {
int& operator[](int);
};
void test_arraylike(ArrayLike a) {
int& ir = a[17];
}
struct SmartRef {
int* operator&();
};
void test_smartref(SmartRef r) {
int* ip = &r;
}
bool& operator,(X, Y);
void test_comma(X x, Y y) {
bool& b1 = (x, y);
X& xr = (x, x); }
struct Callable {
int& operator()(int, double = 2.71828); float& operator()(int, double, long, ...);
double& operator()(float); };
struct Callable2 {
int& operator()(int i = 0);
double& operator()(...) const;
};
struct DerivesCallable : public Callable {
};
void test_callable(Callable c, Callable2 c2, const Callable2& c2c,
DerivesCallable dc) {
int &ir = c(1);
float &fr = c(1, 3.14159, 17, 42);
c();
double &dr = c(1.0f);
int &ir2 = c2();
int &ir3 = c2(1);
double &fr2 = c2c();
int &ir4 = dc(17);
double &fr3 = dc(3.14159f);
}
typedef float FLOAT;
typedef int& INTREF;
typedef INTREF Func1(FLOAT, double);
typedef float& Func2(int, double);
struct ConvertToFunc {
operator Func1*(); operator Func2&(); void operator()();
};
struct ConvertToFuncDerived : ConvertToFunc { };
void test_funcptr_call(ConvertToFunc ctf, ConvertToFuncDerived ctfd) {
int &i1 = ctf(1.0f, 2.0);
float &f1 = ctf((short int)1, 1.0f);
ctf((long int)17, 2.0); ctf();
int &i2 = ctfd(1.0f, 2.0);
float &f2 = ctfd((short int)1, 1.0f);
ctfd((long int)17, 2.0); ctfd();
}
struct HasMember {
int m;
};
struct Arrow1 {
HasMember* operator->();
};
struct Arrow2 {
Arrow1 operator->(); };
void test_arrow(Arrow1 a1, Arrow2 a2, const Arrow2 a3) {
int &i1 = a1->m;
int &i2 = a2->m;
a3->m; }
struct CopyConBase {
};
struct CopyCon : public CopyConBase {
CopyCon(const CopyConBase &Base);
CopyCon(const CopyConBase *Base) {
*this = *Base;
}
};
namespace N {
struct X { };
}
namespace M {
N::X operator+(N::X, N::X);
}
namespace M {
void test_X(N::X x) {
(void)(x + x);
}
}
struct AA { bool operator!=(AA&); };
struct BB : AA {};
bool x(BB y, BB z) { return y != z; }
struct AX {
AX& operator ->(); int b;
};
void m() {
AX a;
a->b = 0; }
struct CircA {
struct CircB& operator->(); int val;
};
struct CircB {
struct CircC& operator->(); };
struct CircC {
struct CircA& operator->(); };
void circ() {
CircA a;
a->val = 0; }
typedef enum {
LastReg = 23,
} Register;
class RegAlloc {
int getPriority(Register r) {
return usepri[r];
}
int usepri[LastReg + 1];
};
namespace pr5546
{
enum { X };
extern const char *const sMoveCommands[][2][2];
const char* a() { return sMoveCommands[X][0][0]; }
const char* b() { return (*(sMoveCommands+X))[0][0]; }
}
namespace pr5512 {
struct Y {
operator short();
operator float();
};
void g_test(Y y) {
short s = 0;
s = y;
}
struct S {};
void operator +=(int&, S);
void f(S s) {
int i = 0;
i += s;
}
struct A {operator int();};
int a;
void b(A x) {
a += x;
}
}
namespace pr5900 {
struct NotAnArray {};
void test0() {
NotAnArray x;
x[0] = 0; }
struct NonConstArray {
int operator[](unsigned); };
int test1() {
const NonConstArray x = NonConstArray();
return x[0]; }
struct NotAFunction {};
void test2() {
NotAFunction x;
x(); }
}
namespace N {
struct X2 { };
}
namespace N2 {
namespace M {
namespace Inner {
template<typename T>
N::X2 &operator<<(N::X2&, const T&);
}
using Inner::operator<<;
}
}
void test_lookup_through_using() {
using namespace N2::M;
N::X2 x;
x << 17;
}
namespace rdar9136502 {
struct X {
int i(); int i(int); };
struct Y {
Y &operator<<(int);
};
void f(X x, Y y) {
y << x
.i; }
}
namespace rdar9222009 {
class StringRef {
inline bool operator==(StringRef LHS, StringRef RHS) { return !(LHS == RHS); }
};
}
namespace PR11784 {
struct A { A& operator=(void (*x)()); };
void f();
void f(int);
void g() { A x; x = f; }
}
namespace test10 {
struct A {
void operator[](float (*fn)(int)); };
float foo(int);
float foo(float);
template <class T> T bar(T);
template <class T, class U> T bar(U);
void test(A &a) {
a[&foo];
a[foo];
a[&bar<int>]; a[bar<int>];
a[&bar<float>];
a[bar<float>];
}
}
struct InvalidOperatorEquals {
InvalidOperatorEquals operator=() = delete; };
namespace PR7681 {
template <typename PT1, typename PT2> class PointerUnion;
void foo(PointerUnion<int*, float*> &Result) {
Result = 1; }
}
namespace PR14995 {
struct B {};
template<typename ...T> void operator++(B, T...) {}
void f() {
B b;
b++; ++b; }
template<typename... T>
struct C {
void operator-- (T...) {}
};
void g() {
C<int> postfix;
C<> prefix;
postfix--; --prefix; }
struct D {};
template<typename T> void operator++(D, T) {}
void h() {
D d;
d++; ++d; }
template<typename...T> struct E {
void operator++(T...) {} };
E<char> e;
struct F {
template<typename... T>
int operator++ (T...) {}
};
int k1 = F().operator++(0, 0);
int k2 = F().operator++('0');
}
namespace ConversionVersusTemplateOrdering {
struct A {
operator short() = delete;
template <typename T> operator T();
} a;
struct B {
template <typename T> operator T();
operator short() = delete;
} b;
int x = a;
int y = b;
}
namespace NoADLForMemberOnlyOperators {
template<typename T> struct A { typename T::error e; }; template<typename T> struct B { int n; };
void f(B<A<void> > b1, B<A<int> > b2, B<A<char> > b3) {
b1 = b1; (void)b1->n; b2[3]; b3 / 0; }
}
namespace PR27027 {
template <class T> void operator+(T, T) = delete; template <class T> void operator+(T) = delete;
struct A {} a_global;
void f() {
A a;
+a; a + a; bool operator+(A);
extern bool operator+(A, A);
+a; a + a;
}
bool test_global_1 = +a_global; bool test_global_2 = a_global + a_global; }
namespace LateADLInNonDependentExpressions {
struct A {};
struct B : A {};
int &operator+(A, A);
int &operator!(A);
int &operator+=(A, A);
int &operator<<(A, A);
int &operator++(A);
int &operator++(A, int);
int &operator->*(A, A);
template<typename T> void f() {
#define idB ((void()), B())
int &a = idB + idB,
&b = !idB,
&c = idB += idB,
&d = idB << idB,
&e = ++idB,
&f = idB++,
&g = idB ->* idB;
}
float &operator+(B, B);
float &operator!(B);
float &operator+=(B, B);
float &operator<<(B, B);
float &operator++(B);
float &operator++(B, int);
float &operator->*(B, B);
template void f<int>();
}