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}} |
Douglas Gregor | 074149e | 2009-01-05 19:45:36 +0000 | [diff] [blame^] | 5 | |
| 6 | enum E { |
| 7 | Enumerator |
| 8 | }; |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 9 | } |
| 10 | namespace Ns { |
| 11 | double f(); // expected-error{{functions that differ only in their return type cannot be overloaded}} |
Douglas Gregor | 074149e | 2009-01-05 19:45:36 +0000 | [diff] [blame^] | 12 | |
| 13 | int x = Enumerator; |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | namespace Ns2 { |
| 17 | float f(); |
| 18 | } |
| 19 | |
Douglas Gregor | 074149e | 2009-01-05 19:45:36 +0000 | [diff] [blame^] | 20 | int y = Ns::Enumerator; |
| 21 | |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 22 | namespace Ns2 { |
| 23 | float f(int); // expected-note{{previous declaration is here}} |
| 24 | } |
| 25 | |
| 26 | namespace Ns2 { |
| 27 | double f(int); // expected-error{{functions that differ only in their return type cannot be overloaded}} |
| 28 | } |
| 29 | |
| 30 | namespace N { |
| 31 | int& f1(); |
| 32 | } |
| 33 | |
| 34 | namespace N { |
| 35 | struct f1 { |
| 36 | static int member; |
| 37 | }; |
| 38 | |
| 39 | void test_f1() { |
| 40 | int &i1 = f1(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | namespace N { |
| 45 | float& f1(int); |
| 46 | |
| 47 | struct f2 { |
| 48 | static int member; |
| 49 | }; |
| 50 | void f2(); |
| 51 | } |
| 52 | |
| 53 | int i1 = N::f1::member; |
| 54 | typedef struct N::f1 type1; |
| 55 | int i2 = N::f2::member; |
| 56 | typedef struct N::f2 type2; |
| 57 | |
| 58 | void test_f1(int i) { |
| 59 | int &v1 = N::f1(); |
| 60 | float &v2 = N::f1(i); |
Chris Lattner | a67865c | 2009-01-05 00:59:08 +0000 | [diff] [blame] | 61 | int v3 = ::i1; |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 62 | } |
Chris Lattner | a67865c | 2009-01-05 00:59:08 +0000 | [diff] [blame] | 63 | |
Chris Lattner | 83cf05a | 2009-01-05 01:42:04 +0000 | [diff] [blame] | 64 | typedef int f2_type; |
| 65 | namespace a { |
| 66 | typedef int f2_type(int, int); |
| 67 | |
| 68 | void test_f2() { |
| 69 | ::f2_type(1, 2); // expected-error {{function-style cast to a builtin type can only take one argument}} |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | |
| 74 | |