diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-07 03:37:08 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-07 03:37:08 +0000 |
commit | bbcd0f3ba215d5a8857b224e32b0330586a00dc6 (patch) | |
tree | 2308609a03b6cb5ad435da2773727698496a0777 /test | |
parent | 3646c68676c3c46a026b23d52188ef6e0d856178 (diff) |
Fix handling of module imports adding names to a DeclContext after qualified
name lookup has been performed in that context (this probably only happens in
C++).
1) Whenever we add names to a context, set a flag on it, and if we perform
lookup and discover that the context has had a lookup table built but has the
flag set, update all entries in the lookup table with additional names from
the external source.
2) When marking a DeclContext as having external visible decls, mark the
context in which lookup is performed, not the one we are adding. These won't
be the same if we're adding another copy of a pre-existing namespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174577 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Modules/Inputs/namespaces-left.h | 7 | ||||
-rw-r--r-- | test/Modules/Inputs/namespaces-right.h | 7 | ||||
-rw-r--r-- | test/Modules/namespaces.cpp | 25 |
3 files changed, 33 insertions, 6 deletions
diff --git a/test/Modules/Inputs/namespaces-left.h b/test/Modules/Inputs/namespaces-left.h index 7e9002aea8..bd192afd2e 100644 --- a/test/Modules/Inputs/namespaces-left.h +++ b/test/Modules/Inputs/namespaces-left.h @@ -1,5 +1,12 @@ @import namespaces_top; +float &global(float); +float &global2(float); + +namespace LookupBeforeImport { + float &f(float); +} + namespace N1 { } namespace N1 { diff --git a/test/Modules/Inputs/namespaces-right.h b/test/Modules/Inputs/namespaces-right.h index b18aeb4478..77f54ead65 100644 --- a/test/Modules/Inputs/namespaces-right.h +++ b/test/Modules/Inputs/namespaces-right.h @@ -1,5 +1,12 @@ @import namespaces_top; +double &global(double); +double &global2(double); + +namespace LookupBeforeImport { + double &f(double); +} + namespace N2 { } namespace N2 { } diff --git a/test/Modules/namespaces.cpp b/test/Modules/namespaces.cpp index 871ae793d3..151e7ea101 100644 --- a/test/Modules/namespaces.cpp +++ b/test/Modules/namespaces.cpp @@ -1,9 +1,8 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -// Importing modules which add declarations to a pre-existing non-imported -// overload set does not currently work. -// XFAIL: * +int &global(int); +int &global2(int); namespace N6 { char &f(char); @@ -11,6 +10,13 @@ namespace N6 { namespace N8 { } +namespace LookupBeforeImport { + int &f(int); +} +void testEarly() { + int &r = LookupBeforeImport::f(1); +} + @import namespaces_left; @import namespaces_right; @@ -18,10 +24,18 @@ void test() { int &ir1 = N1::f(1); int &ir2 = N2::f(1); int &ir3 = N3::f(1); + int &ir4 = global(1); + int &ir5 = ::global2(1); float &fr1 = N1::f(1.0f); float &fr2 = N2::f(1.0f); + float &fr3 = global(1.0f); + float &fr4 = ::global2(1.0f); + float &fr5 = LookupBeforeImport::f(1.0f); double &dr1 = N2::f(1.0); double &dr2 = N3::f(1.0); + double &dr3 = global(1.0); + double &dr4 = ::global2(1.0); + double &dr5 = LookupBeforeImport::f(1.0); } // Test namespaces merged without a common first declaration. @@ -54,11 +68,10 @@ void testMergedMerged() { // Test merging when using anonymous namespaces, which does not // actually perform any merging. -// other file: expected-note{{passing argument to parameter here}} void testAnonymousNotMerged() { N11::consumeFoo(N11::getFoo()); // expected-error{{cannot initialize a parameter of type 'N11::<anonymous>::Foo *' with an rvalue of type 'N11::<anonymous>::Foo *'}} N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a parameter of type 'N12::<anonymous>::Foo *' with an rvalue of type 'N12::<anonymous>::Foo *'}} } - -// other file: expected-note{{passing argument to parameter here}} +// namespaces-right.h: expected-note@60 {{passing argument to parameter here}} +// namespaces-right.h: expected-note@67 {{passing argument to parameter here}} |