summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-02-07 03:37:08 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-02-07 03:37:08 +0000
commit645d755d3e40bfb57f19ab7c474b832b71f3b095 (patch)
tree31de144326a7759ce327c929fc73bc40c836bf80 /clang/test
parent9ce12e36abf44b6373b88610f3c73fbbbdee9b36 (diff)
downloadbcm5719-llvm-645d755d3e40bfb57f19ab7c474b832b71f3b095.tar.gz
bcm5719-llvm-645d755d3e40bfb57f19ab7c474b832b71f3b095.zip
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. llvm-svn: 174577
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Modules/Inputs/namespaces-left.h7
-rw-r--r--clang/test/Modules/Inputs/namespaces-right.h7
-rw-r--r--clang/test/Modules/namespaces.cpp25
3 files changed, 33 insertions, 6 deletions
diff --git a/clang/test/Modules/Inputs/namespaces-left.h b/clang/test/Modules/Inputs/namespaces-left.h
index 7e9002aea8c..bd192afd2e8 100644
--- a/clang/test/Modules/Inputs/namespaces-left.h
+++ b/clang/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/clang/test/Modules/Inputs/namespaces-right.h b/clang/test/Modules/Inputs/namespaces-right.h
index b18aeb44786..77f54ead65a 100644
--- a/clang/test/Modules/Inputs/namespaces-right.h
+++ b/clang/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/clang/test/Modules/namespaces.cpp b/clang/test/Modules/namespaces.cpp
index 871ae793d31..151e7ea1014 100644
--- a/clang/test/Modules/namespaces.cpp
+++ b/clang/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}}
OpenPOWER on IntegriCloud