summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/decltype-call3.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/decltype-call3.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/decltype-call3.C132
1 files changed, 132 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-call3.C b/gcc/testsuite/g++.dg/cpp0x/decltype-call3.C
new file mode 100644
index 00000000000..27797a2fa31
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype-call3.C
@@ -0,0 +1,132 @@
+// Testcase for N3276 and operator overloading
+// { dg-require-effective-target c++11 }
+
+struct A;
+struct B {
+ A operator()(int);
+ A operator[](int);
+ A operator=(int);
+ A operator+=(int);
+ A operator-=(int);
+ A operator*=(int);
+ A operator/=(int);
+ A operator^=(int);
+ A operator&=(int);
+ A operator|=(int);
+ A operator<<=(int);
+ A operator>>=(int);
+};
+
+A operator-(B);
+A operator+(B);
+A operator*(B);
+A operator&(B);
+A operator!(B);
+A operator~(B);
+A operator++(B);
+A operator--(B);
+
+A operator+(B,B);
+A operator-(B,B);
+A operator*(B,B);
+A operator/(B,B);
+A operator%(B,B);
+A operator^(B,B);
+A operator&(B,B);
+A operator|(B,B);
+A operator<(B,B);
+A operator>(B,B);
+A operator,(B,B);
+A operator<<(B,B);
+A operator>>(B,B);
+A operator==(B,B);
+A operator->*(B,B);
+
+#define TRY(E) static_cast<decltype(E)*>(0)
+
+template <class B>
+void f()
+{
+ B b;
+ TRY(b(0));
+ TRY(b[0]);
+ TRY(b=0);
+ TRY(b+=0);
+ TRY(b-=0);
+ TRY(b*=0);
+ TRY(b/=0);
+ TRY(b^=0);
+ TRY(b&=0);
+ TRY(b|=0);
+ TRY(b<<=0);
+ TRY(b>>=0);
+
+ TRY(-b);
+ TRY(+b);
+ TRY(*b);
+ TRY(&b);
+ TRY(!b);
+ TRY(~b);
+ TRY(++b);
+ TRY(--b);
+
+ TRY(b+b);
+ TRY(b-b);
+ TRY(b*b);
+ TRY(b/b);
+ TRY(b%b);
+ TRY(b^b);
+ TRY(b&b);
+ TRY(b|b);
+ TRY(b>b);
+ TRY(b<b);
+ TRY((b,b));
+ TRY(b<<b);
+ TRY(b>>b);
+ TRY(b==b);
+ TRY(b->*b);
+}
+
+int main()
+{
+ B b;
+ TRY(b(0));
+ TRY(b[0]);
+ TRY(b=0);
+ TRY(b+=0);
+ TRY(b-=0);
+ TRY(b*=0);
+ TRY(b/=0);
+ TRY(b^=0);
+ TRY(b&=0);
+ TRY(b|=0);
+ TRY(b<<=0);
+ TRY(b>>=0);
+
+ TRY(-b);
+ TRY(+b);
+ TRY(*b);
+ TRY(&b);
+ TRY(!b);
+ TRY(~b);
+ TRY(++b);
+ TRY(--b);
+
+ TRY(b+b);
+ TRY(b-b);
+ TRY(b*b);
+ TRY(b/b);
+ TRY(b%b);
+ TRY(b^b);
+ TRY(b&b);
+ TRY(b|b);
+ TRY(b>b);
+ TRY(b<b);
+ TRY((b,b));
+ TRY(b<<b);
+ TRY(b>>b);
+ TRY(b==b);
+ TRY(b->*b);
+
+ f<B>();
+}