xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/member-operator-expr.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc class X {
4*f4a2713aSLionel Sambuc public:
5*f4a2713aSLionel Sambuc   int operator++();
6*f4a2713aSLionel Sambuc   operator int();
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
test()9*f4a2713aSLionel Sambuc void test() {
10*f4a2713aSLionel Sambuc   X x;
11*f4a2713aSLionel Sambuc   int i;
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc   i = x.operator++();
14*f4a2713aSLionel Sambuc   i = x.operator int();
15*f4a2713aSLionel Sambuc   x.operator--(); // expected-error{{no member named 'operator--'}}
16*f4a2713aSLionel Sambuc   x.operator float(); // expected-error{{no member named 'operator float'}}
17*f4a2713aSLionel Sambuc   x.operator; // expected-error{{expected a type}}
18*f4a2713aSLionel Sambuc }
19*f4a2713aSLionel Sambuc 
test2()20*f4a2713aSLionel Sambuc void test2() {
21*f4a2713aSLionel Sambuc   X *x;
22*f4a2713aSLionel Sambuc   int i;
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc   i = x->operator++();
25*f4a2713aSLionel Sambuc   i = x->operator int();
26*f4a2713aSLionel Sambuc   x->operator--(); // expected-error{{no member named 'operator--'}}
27*f4a2713aSLionel Sambuc   x->operator float(); // expected-error{{no member named 'operator float'}}
28*f4a2713aSLionel Sambuc   x->operator; // expected-error{{expected a type}}
29*f4a2713aSLionel Sambuc }
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc namespace pr13157 {
operator ()(int x,int y=2,...)32*f4a2713aSLionel Sambuc   class A { public: void operator()(int x, int y = 2, ...) {} };
f()33*f4a2713aSLionel Sambuc   void f() { A()(1); }
34*f4a2713aSLionel Sambuc }