diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-01-09 17:30:44 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-01-09 17:30:44 +0000 |
| commit | cfe7dc6b2f694ca0a18698e830a0dcb4c7dfe979 (patch) | |
| tree | a3b3455b0d5e13ee38987819113ea8dd98de2a7d /clang/test/Modules | |
| parent | f9d0cc016080e217daeb6e200cbd9839bf5aa78b (diff) | |
| download | bcm5719-llvm-cfe7dc6b2f694ca0a18698e830a0dcb4c7dfe979.tar.gz bcm5719-llvm-cfe7dc6b2f694ca0a18698e830a0dcb4c7dfe979.zip | |
Implement redeclaration merging for namespaces defined in distinct
modules. Teach name lookup into namespaces to search in each of the
merged DeclContexts as well as the (now-primary) DeclContext. This
supports the common case where two different modules put something
into the same namespace.
llvm-svn: 147778
Diffstat (limited to 'clang/test/Modules')
| -rw-r--r-- | clang/test/Modules/Inputs/namespaces-left.h | 16 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/namespaces-right.h | 11 | ||||
| -rw-r--r-- | clang/test/Modules/namespaces.cpp | 21 |
3 files changed, 48 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/namespaces-left.h b/clang/test/Modules/Inputs/namespaces-left.h index 85e6d7dc607..6835cda0c4f 100644 --- a/clang/test/Modules/Inputs/namespaces-left.h +++ b/clang/test/Modules/Inputs/namespaces-left.h @@ -9,3 +9,19 @@ namespace N1 { namespace N2 { float& f(float); } + + + + + +namespace N5 { + int &f(int); +} + +namespace N6 { + int &f(int); +} + +namespace N7 { + int &f(int); +} diff --git a/clang/test/Modules/Inputs/namespaces-right.h b/clang/test/Modules/Inputs/namespaces-right.h index 23c88bdbe9b..0afef073c31 100644 --- a/clang/test/Modules/Inputs/namespaces-right.h +++ b/clang/test/Modules/Inputs/namespaces-right.h @@ -16,3 +16,14 @@ namespace N3 { double& f(double); } +namespace N5 { + double &f(double); +} + +namespace N6 { + double &f(double); +} + +namespace N7 { + double &f(double); +} diff --git a/clang/test/Modules/namespaces.cpp b/clang/test/Modules/namespaces.cpp index 75557ba4c14..e1a8d6e8b09 100644 --- a/clang/test/Modules/namespaces.cpp +++ b/clang/test/Modules/namespaces.cpp @@ -1,6 +1,10 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify +namespace N6 { + char &f(char); +} + @import namespaces_left; @import namespaces_right; @@ -13,3 +17,20 @@ void test() { double &dr1 = N2::f(1.0); double &dr2 = N3::f(1.0); } + +// Test namespaces merged without a common first declaration. +namespace N5 { + char &f(char); +} + +void testMerged() { + int &ir1 = N5::f(17); + int &ir2 = N6::f(17); + int &ir3 = N7::f(17); + double &fr1 = N5::f(1.0); + double &fr2 = N6::f(1.0); + double &fr3 = N7::f(1.0); + char &cr1 = N5::f('a'); + char &cr2 = N6::f('b'); +} + |

