| 1 |
// { dg-additional-options "-fdump-tree-gimple" } |
| 2 |
#![feature(rustc_attrs)] |
| 3 |
|
| 4 |
#[rustc_builtin_macro] |
| 5 |
macro_rules! concat { |
| 6 |
() => {}; |
| 7 |
} |
| 8 |
|
| 9 |
macro_rules! a { |
| 10 |
() => { |
| 11 |
"hey" |
| 12 |
}; |
| 13 |
($($t:tt)*) => { |
| 14 |
"ho" |
| 15 |
}; |
| 16 |
} |
| 17 |
|
| 18 |
extern "C" { |
| 19 |
fn printf(fmt: *const i8, ...); |
| 20 |
} |
| 21 |
|
| 22 |
fn print_ptr(s: &str) { |
| 23 |
unsafe { |
| 24 |
printf("%p\n\0" as *const str as *const i8, s as *const str); |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
fn print_str(s: &str) { |
| 29 |
unsafe { |
| 30 |
printf( |
| 31 |
"%s\n\0" as *const str as *const i8, |
| 32 |
s as *const str as *const i8, |
| 33 |
); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
// { dg-final { scan-assembler {"abheyho"} } } |
| 38 |
static S: &str = concat!("a", 'b', a!(), a!(b c d e f a!()), '\0'); |
| 39 |
|
| 40 |
fn main() { |
| 41 |
print_ptr(S); |
| 42 |
print_str(S); |
| 43 |
} |