File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
tests/pass/function_calls Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( linkage) ]
2+
3+ // FIXME move this module to a separate crate once aux-build is allowed
4+ // This currently depends on the fact that miri skips the codegen check
5+ // that denies multiple symbols with the same name.
6+ mod first {
7+ #[ no_mangle]
8+ #[ linkage = "weak" ]
9+ extern "C" fn foo ( ) -> i32 {
10+ 1
11+ }
12+
13+ #[ no_mangle]
14+ #[ linkage = "weak" ]
15+ extern "C" fn bar ( ) -> i32 {
16+ 2
17+ }
18+ }
19+
20+ mod second {
21+ #[ no_mangle]
22+ extern "C" fn bar ( ) -> i32 {
23+ 3
24+ }
25+ }
26+
27+ extern "C" {
28+ fn foo ( ) -> i32 ;
29+ fn bar ( ) -> i32 ;
30+ }
31+
32+ fn main ( ) {
33+ unsafe {
34+ // If there is no non-weak definition, the weak definition will be used.
35+ assert_eq ! ( foo( ) , 1 ) ;
36+ // Non-weak definition takes presedence.
37+ assert_eq ! ( bar( ) , 3 ) ;
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments