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