Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 2 | void f(); |
| 3 | void f(int); |
| 4 | void f(int, float); |
| 5 | void f(int, int); |
| 6 | void f(int, ...); |
| 7 | |
| 8 | typedef float Float; |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 9 | void f(int, Float); // expected-note {{previous declaration is here}} |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 10 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 11 | int f(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}} |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 12 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 13 | void g(void); // expected-note {{previous declaration is here}} |
| 14 | int g(); // expected-error {{functions that differ only in their return type cannot be overloaded}} |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 15 | |
Douglas Gregor | 9e7d9de | 2008-12-15 21:24:18 +0000 | [diff] [blame] | 16 | typedef int INT; |
| 17 | |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 18 | class X { |
| 19 | void f(); |
Douglas Gregor | 9e7d9de | 2008-12-15 21:24:18 +0000 | [diff] [blame] | 20 | void f(int); // expected-note {{previous declaration is here}} |
Douglas Gregor | 1ca50c3 | 2008-11-21 15:36:28 +0000 | [diff] [blame] | 21 | void f() const; |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 22 | |
Douglas Gregor | 9e7d9de | 2008-12-15 21:24:18 +0000 | [diff] [blame] | 23 | void f(INT); // expected-error{{cannot be redeclared}} |
| 24 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 25 | 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 Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 28 | |
Eli Friedman | fa0d3f8 | 2013-06-19 22:43:55 +0000 | [diff] [blame] | 29 | static void g(float); // expected-note {{previous declaration is here}} |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 30 | static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}} |
Eli Friedman | fa0d3f8 | 2013-06-19 22:43:55 +0000 | [diff] [blame] | 31 | static void g(float); // expected-error {{class member cannot be redeclared}} |
David Majnemer | 62e9370 | 2013-11-03 23:51:28 +0000 | [diff] [blame] | 32 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 33 | void h(); // expected-note {{previous declaration is here}} |
| 34 | void h() __restrict; // expected-error {{class member cannot be redeclared}} |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 35 | }; |
Rafael Espindola | 7a525ac | 2013-01-12 01:47:40 +0000 | [diff] [blame] | 36 | |
| 37 | int main() {} // expected-note {{previous definition is here}} |
| 38 | int main(int,char**) {} // expected-error {{conflicting types for 'main'}} |