Douglas Gregor | f5c9f9f | 2012-01-07 09:11:48 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
| 2 | // RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify |
| 3 | |
Richard Smith | 1b7f9cb | 2012-03-13 03:12:56 +0000 | [diff] [blame] | 4 | // Importing modules which add declarations to a pre-existing non-imported |
| 5 | // overload set does not currently work. |
| 6 | // XFAIL: * |
| 7 | |
Douglas Gregor | c6c8e0e | 2012-01-09 17:30:44 +0000 | [diff] [blame] | 8 | namespace N6 { |
| 9 | char &f(char); |
| 10 | } |
| 11 | |
Douglas Gregor | 0fdc09f | 2012-01-09 17:38:47 +0000 | [diff] [blame] | 12 | namespace N8 { } |
| 13 | |
Ted Kremenek | 32ad2ee | 2012-03-01 22:07:04 +0000 | [diff] [blame] | 14 | @__experimental_modules_import namespaces_left; |
| 15 | @__experimental_modules_import namespaces_right; |
Douglas Gregor | f5c9f9f | 2012-01-07 09:11:48 +0000 | [diff] [blame] | 16 | |
| 17 | void test() { |
| 18 | int &ir1 = N1::f(1); |
| 19 | int &ir2 = N2::f(1); |
| 20 | int &ir3 = N3::f(1); |
| 21 | float &fr1 = N1::f(1.0f); |
| 22 | float &fr2 = N2::f(1.0f); |
| 23 | double &dr1 = N2::f(1.0); |
| 24 | double &dr2 = N3::f(1.0); |
| 25 | } |
Douglas Gregor | c6c8e0e | 2012-01-09 17:30:44 +0000 | [diff] [blame] | 26 | |
| 27 | // Test namespaces merged without a common first declaration. |
| 28 | namespace N5 { |
| 29 | char &f(char); |
| 30 | } |
| 31 | |
Douglas Gregor | 0fdc09f | 2012-01-09 17:38:47 +0000 | [diff] [blame] | 32 | namespace N10 { |
| 33 | int &f(int); |
| 34 | } |
| 35 | |
Douglas Gregor | c6c8e0e | 2012-01-09 17:30:44 +0000 | [diff] [blame] | 36 | void testMerged() { |
| 37 | int &ir1 = N5::f(17); |
| 38 | int &ir2 = N6::f(17); |
| 39 | int &ir3 = N7::f(17); |
| 40 | double &fr1 = N5::f(1.0); |
| 41 | double &fr2 = N6::f(1.0); |
| 42 | double &fr3 = N7::f(1.0); |
| 43 | char &cr1 = N5::f('a'); |
| 44 | char &cr2 = N6::f('b'); |
| 45 | } |
| 46 | |
Douglas Gregor | 0fdc09f | 2012-01-09 17:38:47 +0000 | [diff] [blame] | 47 | // Test merging of declarations within namespaces that themselves were |
| 48 | // merged without a common first declaration. |
| 49 | void testMergedMerged() { |
| 50 | int &ir1 = N8::f(17); |
| 51 | int &ir2 = N9::f(17); |
| 52 | int &ir3 = N10::f(17); |
| 53 | } |
Douglas Gregor | 1c3875d | 2012-01-09 18:07:24 +0000 | [diff] [blame] | 54 | |
| 55 | // Test merging when using anonymous namespaces, which does not |
| 56 | // actually perform any merging. |
| 57 | // other file: expected-note{{passing argument to parameter here}} |
| 58 | void testAnonymousNotMerged() { |
| 59 | N11::consumeFoo(N11::getFoo()); // expected-error{{cannot initialize a parameter of type 'N11::<anonymous>::Foo *' with an rvalue of type 'N11::<anonymous>::Foo *'}} |
| 60 | N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a parameter of type 'N12::<anonymous>::Foo *' with an rvalue of type 'N12::<anonymous>::Foo *'}} |
| 61 | } |
| 62 | |
| 63 | |
| 64 | // other file: expected-note{{passing argument to parameter here}} |