2012-01-07 17:11:48 +08:00
// RUN: rm -rf %t
2015-06-16 08:08:24 +08:00
// RUN: %clang_cc1 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
2012-01-07 17:11:48 +08:00
2013-02-07 11:37:08 +08:00
int & global ( int ) ;
int & global2 ( int ) ;
2012-03-13 11:12:56 +08:00
2012-01-10 01:30:44 +08:00
namespace N6 {
char & f ( char ) ;
}
2012-01-10 01:38:47 +08:00
namespace N8 { }
2013-02-07 11:37:08 +08:00
namespace LookupBeforeImport {
int & f ( int ) ;
}
void testEarly ( ) {
int & r = LookupBeforeImport : : f ( 1 ) ;
}
2012-12-12 06:11:52 +08:00
@ import namespaces_left ;
@ import namespaces_right ;
2012-01-07 17:11:48 +08:00
void test ( ) {
int & ir1 = N1 : : f ( 1 ) ;
int & ir2 = N2 : : f ( 1 ) ;
int & ir3 = N3 : : f ( 1 ) ;
2013-02-07 11:37:08 +08:00
int & ir4 = global ( 1 ) ;
int & ir5 = : : global2 ( 1 ) ;
2012-01-07 17:11:48 +08:00
float & fr1 = N1 : : f ( 1.0f ) ;
float & fr2 = N2 : : f ( 1.0f ) ;
2013-02-07 11:37:08 +08:00
float & fr3 = global ( 1.0f ) ;
float & fr4 = : : global2 ( 1.0f ) ;
float & fr5 = LookupBeforeImport : : f ( 1.0f ) ;
2012-01-07 17:11:48 +08:00
double & dr1 = N2 : : f ( 1.0 ) ;
double & dr2 = N3 : : f ( 1.0 ) ;
2013-02-07 11:37:08 +08:00
double & dr3 = global ( 1.0 ) ;
double & dr4 = : : global2 ( 1.0 ) ;
double & dr5 = LookupBeforeImport : : f ( 1.0 ) ;
2014-03-25 09:14:22 +08:00
struct AddAndReexportBeforeImport : : S s ;
int k = AddAndReexportBeforeImport : : S ;
2012-01-07 17:11:48 +08:00
}
2012-01-10 01:30:44 +08:00
// Test namespaces merged without a common first declaration.
namespace N5 {
char & f ( char ) ;
}
2012-01-10 01:38:47 +08:00
namespace N10 {
int & f ( int ) ;
}
2012-01-10 01:30:44 +08:00
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 ' ) ;
}
2012-01-10 01:38:47 +08:00
// Test merging of declarations within namespaces that themselves were
// merged without a common first declaration.
void testMergedMerged ( ) {
int & ir1 = N8 : : f ( 17 ) ;
int & ir2 = N9 : : f ( 17 ) ;
int & ir3 = N10 : : f ( 17 ) ;
}
2012-01-10 02:07:24 +08:00
// Test merging when using anonymous namespaces, which does not
// actually perform any merging.
void testAnonymousNotMerged ( ) {
2014-04-02 13:58:29 +08:00
N11 : : consumeFoo ( N11 : : getFoo ( ) ) ; // expected-error{{cannot initialize a parameter of type 'N11::(anonymous namespace)::Foo *' with an rvalue of type 'N11::(anonymous namespace)::Foo *'}}
N12 : : consumeFoo ( N12 : : getFoo ( ) ) ; // expected-error{{cannot initialize a parameter of type 'N12::(anonymous namespace)::Foo *' with an rvalue of type 'N12::(anonymous namespace)::Foo *'}}
2012-01-10 02:07:24 +08:00
}
2013-04-17 16:06:46 +08:00
// expected-note@Inputs/namespaces-right.h:60 {{passing argument to parameter here}}
// expected-note@Inputs/namespaces-right.h:67 {{passing argument to parameter here}}
2013-09-09 15:34:56 +08:00
// Test that bringing in one name from an overload set does not hide the rest.
void testPartialImportOfOverloadSet ( ) {
void ( * p ) ( ) = N13 : : p ;
p ( ) ;
N13 : : f ( 0 ) ;
}