File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -405,6 +405,11 @@ fn test_lift_const() {
405405 transpile ( "lift_const.c" ) . run ( ) ;
406406}
407407
408+ #[ test]
409+ fn test_macro_fns ( ) {
410+ transpile ( "macro_fns.c" ) . run ( ) ;
411+ }
412+
408413#[ test]
409414fn test_macrocase ( ) {
410415 transpile ( "macrocase.c" ) . run ( ) ;
Original file line number Diff line number Diff line change 1+ #define CONST 42
2+
3+ #define ID (x ) x
4+ #define PAREN (x ) (x)
5+ #define LIT_ID ID(42)
6+ #define LIT_PAREN PAREN(42)
7+ #define CONST_ID ID(CONST)
8+ #define CONST_PAREN PAREN(CONST)
9+ #define NESTED_ID (x ) ID(x)
10+ #define NESTED_PAREN (x ) PAREN(x)
11+
12+ void basic (void ) {
13+ int id = ID (42 );
14+ int paren = PAREN (42 );
15+ int lit_id = LIT_ID ;
16+ int lit_paren = LIT_PAREN ;
17+ int const_id = CONST_ID ;
18+ int const_paren = CONST_PAREN ;
19+ int nested_id = NESTED_ID (42 );
20+ int nested_paren = NESTED_PAREN (42 );
21+ }
Original file line number Diff line number Diff line change 1+ -- -
2+ source : c2rust - transpile / tests / snapshots .rs
3+ expression : cat tests / snapshots / macro_fns .2021.clang15 .rs
4+ -- -
5+ #! [allow (
6+ clippy ::missing_safety_doc ,
7+ dead_code ,
8+ non_camel_case_types ,
9+ non_snake_case ,
10+ non_upper_case_globals ,
11+ unused_assignments ,
12+ unused_mut
13+ )]
14+ pub const LIT_PAREN: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
15+ pub const CONST_PAREN: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
16+ #[no_mangle ]
17+ pub unsafe extern " C" fn basic () {
18+ let mut id: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
19+ let mut paren: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
20+ let mut lit_id: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
21+ let mut lit_paren: ::core ::ffi ::c_int = LIT_PAREN ;
22+ let mut const_id: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
23+ let mut const_paren: ::core ::ffi ::c_int = CONST_PAREN ;
24+ let mut nested_id: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
25+ let mut nested_paren: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
26+ }
Original file line number Diff line number Diff line change 1+ -- -
2+ source : c2rust - transpile / tests / snapshots .rs
3+ expression : cat tests / snapshots / macro_fns .2024.clang15 .rs
4+ -- -
5+ #! [allow (
6+ clippy ::missing_safety_doc ,
7+ dead_code ,
8+ non_camel_case_types ,
9+ non_snake_case ,
10+ non_upper_case_globals ,
11+ unsafe_op_in_unsafe_fn ,
12+ unused_assignments ,
13+ unused_mut
14+ )]
15+ pub const LIT_PAREN: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
16+ pub const CONST_PAREN: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
17+ #[unsafe (no_mangle )]
18+ pub unsafe extern " C" fn basic () {
19+ let mut id: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
20+ let mut paren: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
21+ let mut lit_id: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
22+ let mut lit_paren: ::core ::ffi ::c_int = LIT_PAREN ;
23+ let mut const_id: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
24+ let mut const_paren: ::core ::ffi ::c_int = CONST_PAREN ;
25+ let mut nested_id: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
26+ let mut nested_paren: ::core ::ffi ::c_int = 42 as ::core ::ffi ::c_int ;
27+ }
You can’t perform that action at this time.
0 commit comments