blob: 1201396996e75ff8af74cdef92fe0ad917e35fbb [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00002void f();
3void f(int);
4void f(int, float);
5void f(int, int);
6void f(int, ...);
7
8typedef float Float;
Chris Lattner5f4a6822008-11-23 23:12:31 +00009void f(int, Float); // expected-note {{previous declaration is here}}
Douglas Gregor8e9bebd2008-10-21 16:13:35 +000010
Chris Lattner5f4a6822008-11-23 23:12:31 +000011int f(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
Douglas Gregor8e9bebd2008-10-21 16:13:35 +000012
Chris Lattner5f4a6822008-11-23 23:12:31 +000013void g(void); // expected-note {{previous declaration is here}}
14int g(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
Douglas Gregor8e9bebd2008-10-21 16:13:35 +000015
Douglas Gregor9e7d9de2008-12-15 21:24:18 +000016typedef int INT;
17
Douglas Gregor8e9bebd2008-10-21 16:13:35 +000018class X {
19 void f();
Douglas Gregor9e7d9de2008-12-15 21:24:18 +000020 void f(int); // expected-note {{previous declaration is here}}
Douglas Gregor1ca50c32008-11-21 15:36:28 +000021 void f() const;
Douglas Gregor8e9bebd2008-10-21 16:13:35 +000022
Douglas Gregor9e7d9de2008-12-15 21:24:18 +000023 void f(INT); // expected-error{{cannot be redeclared}}
24
Chris Lattner5f4a6822008-11-23 23:12:31 +000025 void g(int); // expected-note {{previous declaration is here}}
26 void g(int, float); // expected-note {{previous declaration is here}}
27 int g(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
Douglas Gregor8e9bebd2008-10-21 16:13:35 +000028
Eli Friedmanfa0d3f82013-06-19 22:43:55 +000029 static void g(float); // expected-note {{previous declaration is here}}
Chris Lattner5f4a6822008-11-23 23:12:31 +000030 static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}}
Eli Friedmanfa0d3f82013-06-19 22:43:55 +000031 static void g(float); // expected-error {{class member cannot be redeclared}}
David Majnemer62e93702013-11-03 23:51:28 +000032
Stephen Hines0e2c34f2015-03-23 12:09:02 -070033 void h(); // expected-note {{previous declaration is here}}
34 void h() __restrict; // expected-error {{class member cannot be redeclared}}
Douglas Gregor8e9bebd2008-10-21 16:13:35 +000035};
Rafael Espindola7a525ac2013-01-12 01:47:40 +000036
37int main() {} // expected-note {{previous definition is here}}
38int main(int,char**) {} // expected-error {{conflicting types for 'main'}}