Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | namespace Ns { |
| 4 | int f(); // expected-note{{previous declaration is here}} |
| 5 | } |
| 6 | namespace Ns { |
| 7 | double f(); // expected-error{{functions that differ only in their return type cannot be overloaded}} |
| 8 | } |
| 9 | |
| 10 | namespace Ns2 { |
| 11 | float f(); |
| 12 | } |
| 13 | |
| 14 | namespace Ns2 { |
| 15 | float f(int); // expected-note{{previous declaration is here}} |
| 16 | } |
| 17 | |
| 18 | namespace Ns2 { |
| 19 | double f(int); // expected-error{{functions that differ only in their return type cannot be overloaded}} |
| 20 | } |
| 21 | |
| 22 | namespace N { |
| 23 | int& f1(); |
| 24 | } |
| 25 | |
| 26 | namespace N { |
| 27 | struct f1 { |
| 28 | static int member; |
| 29 | }; |
| 30 | |
| 31 | void test_f1() { |
| 32 | int &i1 = f1(); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | namespace N { |
| 37 | float& f1(int); |
| 38 | |
| 39 | struct f2 { |
| 40 | static int member; |
| 41 | }; |
| 42 | void f2(); |
| 43 | } |
| 44 | |
| 45 | int i1 = N::f1::member; |
| 46 | typedef struct N::f1 type1; |
| 47 | int i2 = N::f2::member; |
| 48 | typedef struct N::f2 type2; |
| 49 | |
| 50 | void test_f1(int i) { |
| 51 | int &v1 = N::f1(); |
| 52 | float &v2 = N::f1(i); |
Chris Lattner | a67865c | 2009-01-05 00:59:08 +0000 | [diff] [blame] | 53 | int v3 = ::i1; |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 54 | } |
Chris Lattner | a67865c | 2009-01-05 00:59:08 +0000 | [diff] [blame] | 55 | |