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