xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/overload-decl.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc void f();
3*f4a2713aSLionel Sambuc void f(int);
4*f4a2713aSLionel Sambuc void f(int, float);
5*f4a2713aSLionel Sambuc void f(int, int);
6*f4a2713aSLionel Sambuc void f(int, ...);
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc typedef float Float;
9*f4a2713aSLionel Sambuc void f(int, Float); // expected-note {{previous declaration is here}}
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc int f(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc void g(void); // expected-note {{previous declaration is here}}
14*f4a2713aSLionel Sambuc int g(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc typedef int INT;
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc class X {
19*f4a2713aSLionel Sambuc   void f();
20*f4a2713aSLionel Sambuc   void f(int); // expected-note {{previous declaration is here}}
21*f4a2713aSLionel Sambuc   void f() const;
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc   void f(INT); // expected-error{{cannot be redeclared}}
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc   void g(int); // expected-note {{previous declaration is here}}
26*f4a2713aSLionel Sambuc   void g(int, float); // expected-note {{previous declaration is here}}
27*f4a2713aSLionel Sambuc   int g(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc   static void g(float); // expected-note {{previous declaration is here}}
30*f4a2713aSLionel Sambuc   static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}}
31*f4a2713aSLionel Sambuc   static void g(float); // expected-error {{class member cannot be redeclared}}
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc   void h(); // expected-note {{previous declaration is here}} \
34*f4a2713aSLionel Sambuc                expected-note {{previous declaration is here}}
35*f4a2713aSLionel Sambuc   void h() __restrict; // expected-error {{class member cannot be redeclared}} \
36*f4a2713aSLionel Sambuc                           expected-error {{conflicting types for 'h'}}
37*f4a2713aSLionel Sambuc };
38*f4a2713aSLionel Sambuc 
main()39*f4a2713aSLionel Sambuc int main() {} // expected-note {{previous definition is here}}
main(int,char **)40*f4a2713aSLionel Sambuc int main(int,char**) {} // expected-error {{conflicting types for 'main'}}
41