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 | |
| 29 | static void g(float); |
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}} |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 31 | }; |