summaryrefslogtreecommitdiff
path: root/test/SemaCXX/overload-decl.cpp
blob: 9bba47adfddaa628622be5bcfdc372f35c01ea7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// RUN: %clang_cc1 -fsyntax-only -verify %s 
void f();
void f(int);
void f(int, float); 
void f(int, int);
void f(int, ...);

typedef float Float;
void f(int, Float); // expected-note {{previous declaration is here}}

int f(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}

void g(void); // expected-note {{previous declaration is here}}
int g(); // expected-error {{functions that differ only in their return type cannot be overloaded}}

typedef int INT;

class X {
  void f();
  void f(int); // expected-note {{previous declaration is here}}
  void f() const;

  void f(INT); // expected-error{{cannot be redeclared}}

  void g(int); // expected-note {{previous declaration is here}}
  void g(int, float); // expected-note {{previous declaration is here}}
  int g(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}

  static void g(float);
  static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}}
};

int main() {} // expected-note {{previous definition is here}}
int main(int,char**) {} // expected-error {{conflicting types for 'main'}}