aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/macros/builtin/recurse2.rs
blob: 73e6ab4aa6cd3d74eb6312385bd6b66ea18a6fa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// { dg-additional-options "-fdump-tree-gimple" }
#![feature(rustc_attrs)]

#[rustc_builtin_macro]
macro_rules! concat {
    () => {};
}

macro_rules! a {
    () => {
        "hey"
    };
    ($($t:tt)*) => {
        "ho"
    };
}

extern "C" {
    fn printf(fmt: *const i8, ...);
}

fn print_ptr(s: &str) {
    unsafe {
        printf("%p\n\0" as *const str as *const i8, s as *const str);
    }
}

fn print_str(s: &str) {
    unsafe {
        printf(
            "%s\n\0" as *const str as *const i8,
            s as *const str as *const i8,
        );
    }
}

// { dg-final { scan-assembler {"abheyho"} } }
static S: &str = concat!("a", 'b', a!(), a!(b c d e f a!()), '\0');

fn main() {
    print_ptr(S);
    print_str(S);
}